Skip to content
Latchkey

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.

circleci
Saving cache
Error: could not stat path "node_modules": no such file or directory
Skipping cache upload

Common 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

.circleci/config.yml
- checkout
- run: npm ci          # creates node_modules
- save_cache:
    key: v1-deps-{{ checksum "package-lock.json" }}
    paths:
      - node_modules    # exists by now

Use a correct, existing path

  1. Confirm the directory name and that it is relative to the working directory.
  2. List the path in a run step before save_cache to verify it exists.
  3. Cache only directories actually produced by the job.

How to prevent it

  • Order save_cache after the step that creates the path.
  • Verify cache paths against the job's working directory.
  • Keep cached paths to real, produced directories.

Frequently asked questions

What causes ""save_cache: no such file""?
If save_cache runs before the install/build that creates the directory, the path does not exist yet and nothing is saved.
How do I fix "save_cache: no such file"?
Save the cache after the files exist

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card