Yarn classic "--frozen-lockfile" mismatch in CI
Yarn 1 with --frozen-lockfile refuses to modify yarn.lock. When resolution would change the lockfile, it stops and tells you the lockfile needs updating, keeping CI reproducible.
What this error means
yarn install --frozen-lockfile fails with "error Your lockfile needs to be updated, but yarn was run with --frozen-lockfile."
yarn
error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.Common causes
package.json changed without relocking
A dependency was edited but yarn.lock was not regenerated, so a frozen install would need to change it.
The lockfile was not committed
A local install updated yarn.lock but the change was not committed, leaving CI with a stale lock.
How to fix it
Regenerate and commit yarn.lock
- Run
yarn installlocally to update the lockfile. - Commit
yarn.lockwith the manifest change. - Push so the frozen install matches.
Terminal
yarn install
git add yarn.lock package.jsonKeep --frozen-lockfile in CI
Run installs frozen in CI so drift fails fast rather than silently rewriting the lock.
.github/workflows/ci.yml
- run: yarn install --frozen-lockfileHow to prevent it
- Commit
yarn.lockin the same commit as any dependency change. - Keep
--frozen-lockfileon in CI. - Resolve lock conflicts by re-running
yarn install.
Related guides
Yarn classic "Couldn't find package X required by Y" workspace in CIFix Yarn 1 "Couldn't find package X required by Y on the npm registry" in CI - a workspace dependency is not…
Yarn classic "Integrity check failed" in CIFix Yarn 1 "Integrity check failed" / "incorrect integrity when fetching" in CI - the installed node_modules…
Yarn Berry "YN0028: The lockfile would have been modified" in CIFix Yarn Berry "YN0028: The lockfile would have been modified by this install, which is explicitly forbidden"…