[Bug] "YN0028: The lockfile would have been created by this install, which is explicitly forbidden", but `yarn.lock` exists and is not modified when running `yarn install` locally

See original GitHub issue
  • I’d be willing to implement a fix

Describe the bug

When I run yarn install and then git status I can see that there are no changes since the last commit, i. e. yarn.lock does not get modified by running yarn install.

Yet, when I push the commit to CI that has this GitHub Actions step:

      - name: Install dependencies
        run: yarn install

…it fails with:

2021-05-28T13:48:22.9912155Z ➤ YN0028: The lockfile would have been created by this install, which is explicitly forbidden.
2021-05-28T13:48:22.9913523Z ➤ YN0000: Failed with errors in 0s 12ms
2021-05-28T13:48:22.9918681Z ##[error]Process completed with exit code 1.

It’s weird that the error message is saying “created”. I was not able to google up any mentions of this specific error message. All mentions of YN0028 say “modified”, not “created”.

I believe this is a bug since doing yarn install locally does not modify yarn.lock, which exists and is checked into the repo.

To Reproduce

I do not have a minimal reproduction, but here’s a failing CI job: https://github.com/kaliber5/ember-bdd/actions/runs/885833497

It references a commit of a public open source project on GitHub.

I was able to work around the prpblem by setting the YARN_ENABLE_IMMUTABLE_INSTALLS env var to false. But it does not explain why Yarn is not able to use the lockfile.

Environment if relevant (please complete the following information):

  • OS: Ubuntu 20.04
  • Node version: 14
  • Yarn version: 3.0.0-rc.2

Additional context

The project is a Yarn Workspaces monorepo.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
merceyzcommented, May 30, 2021

Running an install in your repo I see the same changes as the CI, some potential reasons:

  • You have a .yarnrc.yml file with packageExtensions higher up the file tree
  • You’ve run yarn set version ... in your home directory so it’s using a different version than your CI (check ~/.yarnrc.yml for a yarnPath config)
2reactions
andrico1234commented, May 16, 2022

I ran across the same issue. I resolve dit by deleting my cache and then reinstalling the dependencies.

The yarn.lock file was then modified by the time the reinstall had completed.

I believe this may have been because I checked in the cache folder initially, and then reverted it. Not sure if this then caused a discrepancy between my local environment and the checked-in repo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

getting YN0028 The lockfile would have been modified by this ...
UPD: I have created a fresh local clone of the repo from GitHub, ran yarn install in it, and it did produce changes...
Read more >
Error Codes | Yarn - Package Manager
YN0028 - FROZEN_LOCKFILE_EXCEPTION. Your lockfile would be modified if Yarn was to finish the install. When passing the --immutable option to yarn install...
Read more >
Yarn lock: how it works and what you risk without maintaining ...
Answer: Well, yarn will, of course, install dependencies freshly added to package.json that are not yet installed and/or not present in yarn.
Read more >
Why is my Node.js build failing because of an outdated Yarn ...
lock file is not generated by the Yarn executable we fail the build to prevent subtle bugs and security issues that could affect...
Read more >
The Ultimate Guide to yarn.lock Lockfiles - Andrew Hansen
The npm ecosystem is a big reason why JavaScript has taken off like a rocket in development communities. The ability to npm install...
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