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.

CI builds fail with "does master exist?"

See original GitHub issue

Affected Packages

@changesets/cli @changesets/git

Problem

It seems that 2.13.0 of @changesets/cli broke our CI builds. (I’m assuming that’s because of the update to @changesets/git.) We now get this when running changeset status on PRs:

🦋  error Error: Failed to find where HEAD diverged from master. Does master exist?
🦋  error     at getDivergedCommit (/opt/hostedtoolcache/node/12.20.1/x64/lib/node_modules/@changesets/cli/node_modules/@changesets/git/dist/git.cjs.dev.js:58:11)
🦋  error     at async getChangedFilesSince (/opt/hostedtoolcache/node/12.20.1/x64/lib/node_modules/@changesets/cli/node_modules/@changesets/git/dist/git.cjs.dev.js:169:22)
🦋  error     at async Object.getChangedPackagesSinceRef (/opt/hostedtoolcache/node/12.20.1/x64/lib/node_modules/@changesets/cli/node_modules/@changesets/git/dist/git.cjs.dev.js:208:24)
🦋  error     at async getStatus (/opt/hostedtoolcache/node/12.20.1/x64/lib/node_modules/@changesets/cli/dist/cli.cjs.dev.js:953:27)
🦋  error     at async run$1 (/opt/hostedtoolcache/node/12.20.1/x64/lib/node_modules/@changesets/cli/dist/cli.cjs.dev.js:1197:11)

We’re running this on Ubuntu machines (“latest” version) in Azure Pipelines. Couldn’t reproduce the problem locally.

Confirmed that installing @changesets/cli version 2.12.0 fixed the problem.

Proposed solution

🤷‍♂️ No clue. Let me know if there is other info I can provide to help debug. Thanks!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:40 (24 by maintainers)

github_iconTop GitHub Comments

5reactions
steve-taylorcommented, Jul 12, 2022

For those of you struggling with this in GitHub Actions workflows triggered by pull requests, here’s what works for me:

  1. Check out the branch rather than the result of merging main into your branch. Also get the full commit history.
    uses: actions/checkout@v3
    with:
      ref: ${{github.event.pull_request.head.sha}}
      fetch-depth: 0
    
  2. The workflow runner hasn’t checked out main locally, so refer to it as origin/main in the changeset status command.
    run: npx changeset status --since origin/main
    
2reactions
will-stonecommented, Jun 14, 2022

For anyone struggling with this in GitLab, I ended up using this in my job:

  script:
    # Required so that Changesets can compare with main branch
    - git config --global --add safe.directory /builds/path/to/project-name
    - git pull -f origin main:main
    - npx changeset status

Please let me know if there’s any major downsides to this approach that I am not aware of 😬

Read more comments on GitHub >

github_iconTop Results From Across the Web

CI builds fail with "does master exist?" · Issue #517 - GitHub
We now get this when running changeset status on PRs: error Error: Failed to find where HEAD diverged from master. Does master exist?...
Read more >
How to avoid broken master with Pipelines for Merged Results ...
Broken master. This can happen when CI pipelines run on the master branch, but don't pass all tests. A red cross mark is...
Read more >
Common Build Problems - Travis CI Docs
One possible cause for builds failing unexpectedly can be calling set -e (also known as set errexit ), either directly in your .travis.yml...
Read more >
Why is my Travis CI build failing with "File Not Found" errors ...
Can anyone see any other reason that the checked-out files, being referenced by absolute paths, should not exist? travis-ci · pytest · Share....
Read more >
Configuration of your jobs with .gitlab-ci.yml
When enabled and the job fails, the pipeline will be successful/green for all intents and purposes, but a "CI build passed with warnings"...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found