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."
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.
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.
- 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.