Skip to content
Latchkey

CircleCI save_cache "path not found" / Empty Cache - Fix

save_cache warns that a path does not exist or stores almost nothing. The directory you listed is wrong, has not been created yet, or the cache step runs before the install that populates it.

What this error means

The job logs "Skipping cache - ... path does not exist" or saves a tiny/empty cache, and the next run still installs from scratch. The cache exists but is useless because it captured the wrong directory.

job log
save_cache
  - Skipping the cache: the path /home/circleci/.npm does not exist
# or
  - Saving cache (0 B)

Common causes

Path does not exist or is wrong

The cache directory differs from where the tool actually writes - e.g. caching node_modules when you should cache ~/.npm, or a path under the wrong home directory for the image user.

save_cache runs before install

If save_cache is placed before the install step, the directory is empty (or absent) when it captures, so nothing useful is stored.

Caching a derived dir instead of the package cache

Caching large build outputs or node_modules directly is fragile; the package manager’s own cache (~/.npm, ~/.cache/pip) restores more reliably.

How to fix it

Cache the right directory, after install

.circleci/config.yml
steps:
  - checkout
  - restore_cache:
      keys: [deps-v1-{{ checksum "package-lock.json" }}]
  - run: npm ci
  - save_cache:
      key: deps-v1-{{ checksum "package-lock.json" }}
      paths:
        - ~/.npm

Confirm the real cache location for the image

  1. Print the package manager cache dir (npm config get cache, pip cache dir).
  2. Use that absolute path in save_cache.paths.
  3. Place save_cache after the step that populates the directory.

How to prevent it

  • Cache the package manager’s cache dir, not node_modules.
  • Always save after install, restore before it.
  • Verify the path exists for the image’s user/home.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →