Skip to content
Latchkey

GitHub Actions cache "tar: ... Cannot open: No such file or directory"

The cache action shells out to tar over the configured path; if that path does not exist at save time (or its parent is missing at restore time), tar fails with "Cannot open: No such file or directory".

What this error means

The cache save or restore step errors with "tar: <path>: Cannot open: No such file or directory", and no cache is written or extracted.

github-actions
tar: /home/runner/.cache/pip: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

Common causes

Cache path not created before save

The directory the cache step is told to save never got created by an earlier step, so tar has nothing to archive.

Wrong or platform-specific path

The path is incorrect for the runner OS (different home or cache location), so it does not resolve.

How to fix it

Ensure the path exists and is correct

  1. Confirm the cache path is actually populated before the cache step.
  2. Use the tool's real cache directory for the runner OS.
  3. Create the directory if a step expects it to pre-exist.
  4. Prefer setup actions' built-in cache where available.
.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/.cache/pip
    key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}

How to prevent it

  • Point cache paths at directories that exist at save time.
  • Account for OS-specific cache locations.
  • Prefer setup-action caching over hand-rolled paths.

Related guides

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