CircleCI save_cache "no such file or directory"
A save_cache step pointed at a path that does not exist when it runs. The directory was never created, has a different name, or the cache step runs before the files are produced.
What this error means
The save_cache step warns or errors that the path does not exist, so nothing is cached and later jobs miss. The build may still pass but never benefits from caching.
Saving cache
Error: could not stat path "node_modules": no such file or directory
Skipping cache uploadCommon causes
Path created after save_cache runs
If save_cache runs before the install/build that creates the directory, the path does not exist yet and nothing is saved.
Wrong path or working directory
A relative path that does not match the job's working directory, or a typo in the directory name, points at nothing.
How to fix it
Save the cache after the files exist
- checkout
- run: npm ci # creates node_modules
- save_cache:
key: v1-deps-{{ checksum "package-lock.json" }}
paths:
- node_modules # exists by nowUse a correct, existing path
- Confirm the directory name and that it is relative to the working directory.
- List the path in a
runstep beforesave_cacheto verify it exists. - Cache only directories actually produced by the job.
How to prevent it
- Order
save_cacheafter the step that creates the path. - Verify cache paths against the job's working directory.
- Keep cached paths to real, produced directories.