Yarn Berry "YN0000: ... couldn't be located" cache miss in CI
Under an immutable install Yarn Berry expects every package to already be present in .yarn/cache. When an archive is missing (and Yarn is not allowed to fetch or write it), it fails saying the package could not be located.
What this error means
yarn install fails with a "YN0000" line reporting a package "couldn't be located" and that fetching it would violate the immutable cache, often after switching to zero-installs partially.
YN0000: Fetch step
YN0013: | lodash@npm:4.17.21 can't be found in the cache and will be fetched from the remote registry
Error: The remote archive for lodash@npm:4.17.21 couldn't be located and the cache is immutableCommon causes
The committed cache is incomplete
Zero-installs requires .yarn/cache to hold every archive; a missing or gitignored entry cannot be fetched under an immutable cache.
A lockfile change without a matching cache update
A dependency was added and yarn.lock updated, but the new archive was never added to .yarn/cache.
How to fix it
Repopulate and commit the cache
- Run
yarn installlocally so the missing archive is fetched into.yarn/cache. - Confirm
.yarn/cacheis committed and not gitignored. - Push so CI finds every archive.
yarn install
git add .yarn/cache yarn.lockOr allow immutable cache to fetch instead
If you do not commit the cache, disable the immutable cache guard so CI can fetch and cache archives itself (then persist via CI cache).
- run: yarn install --immutable --immutable-cache=falseHow to prevent it
- For zero-installs, commit the complete
.yarn/cachewith every lockfile change. - Do not gitignore
.yarn/cacheif you rely on committed archives. - Otherwise cache
.yarn/cachein CI and let Yarn fetch what is missing.