question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nx affected:apps fails with error fatal: Not a valid object name master

See original GitHub issue

Prerequisites

Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • [ x ] I am running the latest version
  • [ x ] I checked the documentation (nx.dev) and found no answer
  • [ x ] I checked to make sure that this issue has not already been filed
  • [ x ] I’m reporting the issue to the correct repository (not related to React, Angular or any dependency)

Expected Behavior

nx affected:apps --plain should display list of affected apps. we use this comma separated list of affected apps to determine what apps to deploy

What is the current behavior? No

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. upgrade to latest nrwl
  2. init workspace
  3. npm run affected:apps – --plain

Context

Please provide any relevant information about your setup:

  • Interesting thing to note, I do not see any error when running from my local machine but from ci.
    A minimal reproduction scenario allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem.

Failure Logs

Please include any relevant log snippets or files here. Above command fails with

> xxx@0.0.0 affected:apps /home/runner/work/xxxx/xxxx
> nx affected:apps

fatal: Not a valid object name master
/home/runner/work/xxxx/xxxx/node_modules/@nrwl/workspace/node_modules/yargs/yargs.js:1109
      else throw err
           ^

Error: Command failed: git merge-base master HEAD
fatal: Not a valid object name master

    at checkExecSyncError (child_process.js:629:11)
    at Object.execSync (child_process.js:666:13)
...
...
...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! thetopper@0.0.0 affected:apps: `nx affected:apps`
npm ERR! Exit status 1
npm ERR! 

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

20reactions
devinshoemakercommented, Apr 6, 2020

@Plysepter ah, thank you! That definitely helped. Here’s my current best working config:

name: Node.js CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x, 12.x]

    steps:
    - uses: actions/checkout@v2
      with:
        ref: ${{ github.event.pull_request.head.ref }}
        fetch-depth: 0
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: git fetch --no-tags --prune --depth=5 origin master
    - run: yarn install --frozen-lockfile
    - run: yarn affected:build --base=origin/master
      env:
        CI: true

I think this issue can be closed now.

10reactions
cprellcommented, Mar 20, 2020

I run affected:build like this:

npm run affected:build -- --base=$NX_BASE

where NX_BASE is different depending on whether a push event or a pull request triggers the workflow.

In case of a push, we want to look at the commit id of the second newest commit, which translates to export NX_BASE=$(git rev-parse HEAD~1)

Keep in mind that you need to use the checkout action earlier with a fetch depth of at least 2 for this to work. - uses: actions/checkout@v2 with: fetch-depth: 2

In case of a pull request, it could look like something like this export NX_BASE_TEMP=$(git log --format=%H -n 1 origin/${{ github.base_ref }})

This is the newest commit id of the target branch. I needed to use git fetch origin beforehand for this to work.

Hope this helps a bit!

Read more comments on GitHub >

github_iconTop Results From Across the Web

NX monorepo fatal: No such ref: 'main~1' - Stack Overflow
Based on the docs, setting the base to main~1 should just compare it to the previous commit of the main branch. Full error...
Read more >
Git Error - fatal: Not a valid object name: 'master' - Code by Amir
fatal : Not a valid object name: 'master'. This error happens when trying to create a branch when there is no master branch....
Read more >
gt nx affected lint… - @Nrwl/Community
nx affected:lint. ... fatal: Not a valid object name master ... Error: Command failed: git merge-base master HEAD fatal: Not a valid object ......
Read more >
affected - CLI command - Nx
Run target for affected projects.
Read more >
Cannot use git commands inside a step - Atlassian Community
Solved: Hi, I keep getting the error `fatal: Not a valid object name master` on commands that use git. Even when fetching all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found