diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e20d618d2..ad20267ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -195,6 +195,28 @@ openshell --help openshell sandbox create -- codex ``` +### Rust build cache + +Mise preserves an existing `SCCACHE_DIR` so each environment can choose where +to store compiler cache entries. When `SCCACHE_DIR` is unset, OpenShell uses +the worktree-local `.cache/sccache` directory. To make cache entries available +to multiple worktrees on a workstation, set the variable to a user-level +directory before activating mise. For example: + +```shell +export SCCACHE_DIR="$HOME/.cache/openshell/sccache" +``` + +CI can select a different directory or configure a remote sccache backend +without changing the workstation setting. Cargo output remains in each +worktree's `target/` directory. + +OpenShell does not set `SCCACHE_BASEDIRS`. Sccache loads base directories when +its machine-local daemon starts, but the correct workspace root differs for +each worktree. Cache reuse therefore depends on the compiler inputs: outputs +that embed absolute paths, including Rust dependencies in some builds, can +still miss across worktrees. + ## Main Tasks These are the primary `mise` tasks for day-to-day development: diff --git a/mise.toml b/mise.toml index fc5ba340a..a5d968210 100644 --- a/mise.toml +++ b/mise.toml @@ -53,11 +53,10 @@ _.file = [".env"] KUBECONFIG = "{{config_root}}/kubeconfig" UV_CACHE_DIR = "{{config_root}}/.cache/uv" -# Enable sccache for faster Rust builds. -# Local builds use a disk cache (SCCACHE_DIR); CI sets SCCACHE_MEMCACHED_ENDPOINT -# via repository variables to use a shared memcached backend instead. +# Enable sccache for faster Rust builds. Preserve an SCCACHE_DIR selected by the +# caller so workstations and CI can configure their cache locations separately. RUSTC_WRAPPER = "sccache" -SCCACHE_DIR = "{{config_root}}/.cache/sccache" +SCCACHE_DIR = "{{ get_env(name='SCCACHE_DIR', default=config_root ~ '/.cache/sccache') }}" # Shared build constants (overridable via environment). # DOCKER_BUILDKIT enables BuildKit for Docker; ignored by podman.