Skip to content
Latchkey

GitLab CI cache "WARNING: ... no such file or directory" in CI

The runner tried to archive or restore a cache and the path is empty or missing, or no cache exists yet. These are warnings: the job continues, but the cache does not help until the path and key are correct.

What this error means

The log shows "WARNING: <path>: no such file or directory" while creating the cache, or "WARNING: file does not exist" / "No URL provided, cache will not be downloaded" when restoring.

GitLab Runner
Creating cache default...
WARNING: node_modules/: no such file or directory
Failed to create cache

Common causes

The cached path was not created before archiving

The job caches node_modules/ but the install step did not run or wrote elsewhere, so there is nothing to archive.

A first run with no existing cache

On the first pipeline for a key, there is no cache to download yet, so the restore warning is expected once.

How to fix it

Cache a path the job actually produces

  1. Run the step that creates the path before the cache is archived.
  2. Point cache:paths at the real output location.
  3. Use a stable cache:key so later runs can restore it.
.gitlab-ci.yml
build:
  cache:
    key:
      files:
        - package-lock.json
    paths:
      - node_modules/
  script:
    - npm ci

Treat a first-run restore warning as normal

The "cache will not be downloaded" warning on the very first run for a key is expected; it should disappear once a cache is created.

How to prevent it

  • Create cached paths before the cache is archived.
  • Use file-based cache keys so caches are reused across runs.
  • Distinguish a benign first-run miss from a persistent cache failure.

Frequently asked questions

What causes ""no such file or directory" (cache)"?
The job caches node_modules/ but the install step did not run or wrote elsewhere, so there is nothing to archive.
How do I fix "no such file or directory" (cache)?
Cache a path the job actually produces

Related guides

References

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