Skip to content
Latchkey

ccache "error: ... Read-only file system" in CI

ccache tried to write into CCACHE_DIR but the filesystem is mounted read-only. It cannot store new objects or update stats, so caching effectively stops.

What this error means

The log shows "ccache: error: Failed to ... Read-only file system" for a path under CCACHE_DIR, often when the cache lives on a read-only container mount or a squashed image layer.

ccache
ccache: error: Failed to write to
/opt/ccache/CACHEDIR.TAG: Read-only file system

Common causes

CCACHE_DIR is on a read-only mount

A container volume, a read-only bind mount, or a baked image layer holds the cache path, so ccache cannot write.

The path is inside an immutable image layer

When the cache directory was baked into the image, it is part of a read-only layer at runtime and cannot be updated.

How to fix it

Move CCACHE_DIR to a writable path

  1. Point CCACHE_DIR at a writable location under the workspace or a tmp volume.
  2. Mount that path read-write if you use a container.
  3. Re-run and confirm ccache writes without the ERROFS error.
Terminal
export CCACHE_DIR="$RUNNER_TEMP/ccache"
mkdir -p "$CCACHE_DIR"

Mount the cache volume read-write

If you pass a volume into a container job, ensure it is not mounted with :ro so ccache can update it.

.github/workflows/ci.yml
container:
  image: gcc:13
  volumes:
    - /host/ccache:/ccache

How to prevent it

  • Keep CCACHE_DIR on a writable workspace or temp path.
  • Never bake the live cache directory into an immutable image layer.
  • Mount cache volumes read-write in container jobs.

Related guides

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