{"id":5719,"library":"sccache","title":"Sccache","description":"Sccache (Shared Compilation Cache) is a ccache-like tool written in Rust that acts as a compiler wrapper to accelerate build times by caching compilation results. It supports C/C++, Rust, and CUDA, and can utilize various local and cloud storage backends like S3, Google Cloud Storage, Redis, and Memcached. The PyPI package for sccache (version 0.14.0) primarily provides access to this binary tool for Python environments. It is actively maintained by Mozilla and a community of contributors, with regular releases providing new features and bug fixes.","status":"active","version":"0.14.0","language":"en","source_language":"en","source_url":"https://github.com/mozilla/sccache","tags":["compiler-cache","build-tool","rust","c-cpp","cuda","build-acceleration","ci-cd"],"install":[{"cmd":"pip install sccache","lang":"bash","label":"Install via pip (downloads binary)"},{"cmd":"cargo install sccache","lang":"bash","label":"Install via Cargo (requires Rust toolchain)"},{"cmd":"brew install sccache","lang":"bash","label":"Install on macOS via Homebrew"},{"cmd":"scoop install sccache","lang":"bash","label":"Install on Windows via Scoop"}],"dependencies":[],"imports":[],"quickstart":{"code":"import os\nimport subprocess\n\n# Ensure sccache is in PATH or set SCCACHE env var if installed elsewhere\n# For simplicity, assuming 'sccache' is callable from PATH after 'pip install sccache'\n\n# Start the sccache server in the background (optional, but recommended for efficiency)\n# The server automatically stops after 10 minutes of inactivity by default.\nsubprocess.run(['sccache', '--start-server'])\n\n# Example usage: Compile a Rust project with sccache\n# This environment variable tells Cargo/rustc to use sccache as a wrapper\nenv = os.environ.copy()\nenv['RUSTC_WRAPPER'] = 'sccache'\n\nprint('Building Rust project with sccache...')\ntry:\n    # Simulate a Rust build command\n    subprocess.run(['cargo', 'build', '--release'], env=env, check=True)\n    print('First build (warming cache) completed.')\n\n    # Run again to demonstrate caching effect\n    subprocess.run(['cargo', 'clean'], check=True)\n    print('Cache cleaned, running second build...')\n    subprocess.run(['cargo', 'build', '--release'], env=env, check=True)\n    print('Second build (should be faster due to cache) completed.')\n\n    # Show sccache statistics\n    subprocess.run(['sccache', '--show-stats'], check=True)\n\nfinally:\n    # Stop the sccache server\n    subprocess.run(['sccache', '--stop-server'])\n    print('Sccache server stopped.')\n","lang":"python","description":"Sccache is primarily used as a command-line wrapper for compilers, configuring your build system to use `sccache` as the compiler executable or wrapper. The PyPI package installs the `sccache` binary. This example demonstrates how to invoke `sccache` via Python's `subprocess` module to wrap a Rust build, showing the typical `RUSTC_WRAPPER` environment variable usage. For C/C++ builds, you would typically set `CC='sccache gcc'` or `CXX='sccache g++'`."},"warnings":[{"fix":"Interact with `sccache` as a shell command-line tool (e.g., via `subprocess.run` in Python) or configure your build system's compiler paths and environment variables (e.g., `RUSTC_WRAPPER`, `CC`, `CXX`). Do not expect to `import sccache` and call Python functions for caching.","message":"The `sccache` PyPI package primarily provides a pre-compiled Rust binary. It does not expose a direct Python API for its core caching functionality. Usage is typically via environment variables or by configuring build systems to use the `sccache` executable as a compiler wrapper.","severity":"gotcha","affected_versions":"0.1.0+"},{"fix":"To prevent premature server shutdown, you can either explicitly restart the server when needed (`sccache --start-server`) or configure a longer inactivity timeout by setting the `SCCACHE_IDLE_TIMEOUT` environment variable (value in seconds) or in the `sccache` configuration file.","message":"By default, the `sccache` server will terminate after 10 minutes of inactivity. This can lead to unexpected server shutdowns during long pauses in development or CI.","severity":"gotcha","affected_versions":"0.1.0+"},{"fix":"To ensure builds gracefully fall back to the local compiler without stopping, set the environment variable `SCCACHE_IGNORE_SERVER_IO_ERROR=1`.","message":"If the `sccache` server fails to communicate (e.g., due to a crash or network issue), `sccache` will, by default, fail the build.","severity":"gotcha","affected_versions":"0.1.0+"},{"fix":"To force `sccache` to overwrite existing cache entries for a given build, set the environment variable `SCCACHE_RECACHE=1` before running your compilation commands. This forces a re-compilation and updates the cache.","message":"If you suspect the cache contains broken build artifacts, subsequent builds might repeatedly use corrupted data.","severity":"gotcha","affected_versions":"0.1.0+"},{"fix":"Ensure you are using the latest version of `mozilla-actions/sccache-action` or any other integration to leverage the updated GitHub Actions cache service. Verify your workflows are not interacting with the decommissioned service by reviewing GitHub's breaking changes notifications.","message":"Older versions of the `mozilla-actions/sccache-action` GitHub Action (and other third-party actions/products using the GitHub Actions cache service) might be impacted by the decommissioning of the old cache service, potentially leading to build failures or lack of caching.","severity":"deprecated","affected_versions":"Dependent on GitHub Actions environment; specifically before official migration in April 2025."}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}