Skip to content
Latchkey

sccache: Usage, Options & Common CI Errors

sccache caches compiler output locally or in shared cloud storage (S3, GCS, Redis).

sccache is the Rust-friendly cousin of ccache, with first-class shared-cache backends so multiple CI runners share one cache. Its added failure modes are the background server process and cloud credentials.

What it does

sccache wraps compiler invocations (C/C++, Rust, and others) and serves cached objects. It runs as a background server and can store the cache locally or in a shared backend - S3, GCS, Azure Blob, Redis, or memcached - so a fleet of runners benefits from each other.

Common usage

Terminal
export RUSTC_WRAPPER=sccache              # cache Rust compiles
export SCCACHE_BUCKET=my-cache SCCACHE_REGION=us-east-1
export CC="sccache gcc" CXX="sccache g++"
sccache --start-server
sccache --show-stats
sccache --stop-server

Options

ItemWhat it does
RUSTC_WRAPPER=sccacheRoute cargo/rustc through sccache
SCCACHE_DIRLocal cache directory
SCCACHE_BUCKET / _REGIONS3 shared-cache backend
--show-statsPrint cache statistics
--start-server / --stop-serverManage the background server
SCCACHE_GHA_ENABLEDUse the GitHub Actions cache backend

Common errors in CI

"sccache: error: failed to execute compile" / "Server startup failed" often means a stale server from a previous job - sccache --stop-server before starting. With an S3 backend, missing or wrong credentials yield "Permission denied (os error 13)" or silent misses - confirm SCCACHE_BUCKET, region, and IAM access. Stats showing "Non-cacheable compilations" mean unsupported flags (e.g. -fprofile, certain -g modes). For Rust, set RUSTC_WRAPPER (not CC) and avoid incremental + sccache together (incremental defeats it).

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →