Yarn Berry cache not persisted (slow install) in CI
Yarn Berry stores package archives in .yarn/cache. If that directory is neither committed (zero-installs) nor cached across CI runs, every job re-downloads all archives, making installs slow and registry-dependent.
What this error means
yarn install shows a full "Fetch step" downloading every package on each run, and job times stay high even when dependencies did not change.
yarn
YN0000: - Fetch step
YN0013: - 812 packages were added to the project (+ 214 MB).
YN0000: - Completed in 1m 48sCommon causes
The .yarn/cache is not persisted
Without a committed cache or a CI cache keyed on yarn.lock, the fetch step starts empty and re-downloads everything.
Global folder used but not cached
With enableGlobalCache, archives live in a global folder that CI also fails to persist, so they are re-fetched.
How to fix it
Cache .yarn/cache keyed on yarn.lock
Persist the local cache across runs so the fetch step reuses archives.
.github/workflows/ci.yml
- uses: actions/cache@v4
with:
path: .yarn/cache
key: yarn-cache-${{ hashFiles('yarn.lock') }}Or use zero-installs and commit the cache
- Set
enableGlobalCache: falseso archives live in.yarn/cache. - Commit
.yarn/cacheso CI needs no fetch at all. - Run
yarn install --immutablein CI.
.yarnrc.yml
enableGlobalCache: falseHow to prevent it
- Cache
.yarn/cachekeyed on the lockfile, or commit it for zero-installs. - Set
enableGlobalCache: falsewhen caching a project-local cache. - Confirm the fetch step reuses rather than re-adds packages.
Related guides
Yarn Berry "The remote server failed to provide the requested resource" in CIFix Yarn Berry "The remote server failed to provide the requested resource" in CI - a registry fetch returned…
Yarn Berry zero-installs failing (.yarn/cache not committed) in CIFix Yarn Berry zero-installs failures in CI - the workflow assumes committed .yarn/cache and .pnp.cjs, but th…
pnpm store not cached (slow install every run) in CIFix slow pnpm installs in CI caused by an uncached content-addressable store - without caching ~/.pnpm-store…