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
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-serverOptions
| Item | What it does |
|---|---|
| RUSTC_WRAPPER=sccache | Route cargo/rustc through sccache |
| SCCACHE_DIR | Local cache directory |
| SCCACHE_BUCKET / _REGION | S3 shared-cache backend |
| --show-stats | Print cache statistics |
| --start-server / --stop-server | Manage the background server |
| SCCACHE_GHA_ENABLED | Use 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).