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 systemCommon 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
- Point CCACHE_DIR at a writable location under the workspace or a tmp volume.
- Mount that path read-write if you use a container.
- 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:/ccacheHow 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
ccache "error: Failed to create temporary file" in CIFix ccache "error: Failed to create temporary file" in CI - the cache directory is missing, not writable by t…
ccache permission denied from container user mismatch in CIFix ccache permission errors in container CI - a restored cache owned by root cannot be written by a non-root…
ccache cache full: CCACHE_MAXSIZE eviction thrashing in CIFix ccache eviction thrashing in CI - the cache exceeds CCACHE_MAXSIZE and older entries are evicted before t…