Skip to content
Latchkey

Earthly "no space left on device" (BuildKit cache) in CI

BuildKit stores layers and its build cache on disk. On a CI runner with a small volume, the cache plus intermediate layers can exhaust the disk mid-build, and the failing step reports "no space left on device".

What this error means

A RUN step or an export fails with "write ...: no space left on device" or "failed to solve: ... no space left on device" partway through an otherwise valid build.

earthly
+build | error: failed to copy files: write /var/lib/buildkit/... : no space left on device
Error: solve: failed to solve: no space left on device

Common causes

The BuildKit cache grew past the disk

Cached layers accumulate across runs on a persistent daemon and are never pruned, filling the volume buildkitd writes to.

Large intermediate layers on a small runner

A hosted runner ships a modest disk; big base images and build outputs can exhaust it in a single run.

How to fix it

Prune the BuildKit cache

Reclaim space by pruning Earthly's cache before or between builds.

Terminal
earthly prune --all

Free disk and cap the cache

  1. Remove unused preinstalled tooling to reclaim runner space.
  2. Set a cache size limit so buildkitd evicts old layers.
  3. Prune between jobs on long-lived self-hosted daemons.
Terminal
# limit the buildkit cache Earthly keeps
export EARTHLY_BUILDKIT_CACHE_SIZE_MB=20000
earthly prune

How to prevent it

  • Cap the BuildKit cache size so it self-evicts.
  • Prune the cache on persistent self-hosted daemons.
  • Use runners with enough disk for your base images.

Related guides

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