Skip to content
Latchkey

tar: "write error: No space left on device" Restoring Cache

A cache archive failed to extract or save because the runner disk filled. The cached payload (dependencies, build outputs) is larger than the remaining free space.

What this error means

The cache step prints tar: write error: No space left on device while unpacking or packing. Clearing other disk usage or using a larger disk resolves it with no workflow change.

shell
Received 0 of 0 (0.0 MB), 0.0 MBs/sec
tar: write error: No space left on device
##[warning] Failed to restore: tar exited with error code 2

Common causes

The cache is larger than the free disk

Big dependency or build caches can outgrow what is left on a small runner once the checkout and tooling are present.

Disk already consumed by prior steps

Earlier build artifacts and downloads leave too little room to extract the cache archive.

How to fix it

Free space before the cache step

Remove unneeded preinstalled SDKs and prune caches early in the job.

shell
df -h
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android
docker system prune --all --force
df -h

Shrink or split the cache

  1. Scope the cache key to only what is needed (avoid caching huge build trees).
  2. Exclude generated artifacts from the cached paths.
  3. Move the job to a runner with a larger disk.

How to prevent it

  • Keep cache payloads tight and scoped.
  • Free preinstalled bloat before restoring large caches.
  • Right-size disk for cache-heavy pipelines.

Related guides

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