Troubleshooting
Find why a build has no hits, unexpected misses, or no remote activity
Start at the root of the affected workspace:
kache doctor
kache stats --last-build --root "$PWD"
kache explain --root "$PWD"
doctor checks setup and cache access. Stats show the latest recorded build
session; explain compares recorded inputs to find miss causes. --root names
the directory that holds the build's target directory, which is the workspace
for the default target/. Without it, both commands describe the newest build
Kache recorded, from any project.
For a functional check of the installed Rust cache pipeline, run kache doctor --probe.
It compiles a temporary library twice in an isolated local cache and checks the
second invocation restores it without compiling. It does not test your remote
cache or the flags and policy of the affected project.
A build shows no hits
First check whether Cargo ran any compiler work. A second build in an already
populated target directory can finish without invoking Kache at all. A new
target directory can also start populated: by default Kache seeds it with the
registry and git dependency units another checkout built with the same rustc,
and Cargo skips them. Those units count as neither hits nor misses. Set
KACHE_SEED_NEW_TARGETS=0 for a build that sends every crate through the cache.
Use the two-worktree walkthrough to test reuse with separate target directories. Keep the revision, toolchain, profile, and features the same. A fresh store needs the first build to populate it.
If Cargo compiles but Kache records no events, run kache doctor in the same
shell or agent environment as the build. Check that Cargo uses the configured
wrapper. For C/C++, check that kache doctor reports the compiler shims as
active in that shell, or that CC/CXX name Kache as in the
prefix method.
A build-script launcher cannot locate kache-engine
If a build script fails with locating kache-engine; reinstall both Kache binaries together, check the executable path in the error. For an ordinary
Kache installation, reinstall the client and engine together.
For a path inside a Cargo target's .kache-build-script-shims/ directory,
v2.1.0 and later provide a repair command that keeps the compiled scripts.
Stop that target's builds and programs, then run:
kache doctor --repair-build-scripts target
cargo build
Use the actual target directory if CARGO_TARGET_DIR points elsewhere. On
Linux and macOS, this command validates Kache's launcher records and preserved
scripts, holds Cargo's profile locks, and switches the records to a new copy of
the installed engine. It leaves the old runtime pins and real scripts intact.
kache init configures future builds; it does not refresh existing runtime pins.
On older releases, or if validation reports a missing or invalid preserved script, use the package cleanup below. Do not copy a client or symlink an arbitrary engine into an old runtime pin: the client and engine must come from the same release.
Repair an invalid build-script launcher
For a missing or invalid preserved build script, or a recursive chain of Kache processes, stop the affected build and its process tree before cleaning outputs. Update Kache to a version containing the launcher fix, then remove the affected package's build outputs and rebuild without importing an old target:
cargo clean -p <package>
KACHE_SEED_NEW_TARGETS=0 cargo build
Replace <package> with the package named by Cargo's failed build-script step.
Older concurrent launcher installations could preserve a launcher in place of
the real script. Existing launchers keep their pinned Kache until their package
is rebuilt, so repeat the cleanup in each affected worktree. The updated
launcher detects recursive fallback, and new build-script compilation keys
retire older cache entries. A full cache deletion is unnecessary.
Some units always compile
Open kache monitor and check the Why tab, or save a report:
kache stats --full --last-build --format markdown --output kache-report.md
A passthrough means the invocation was outside the caching policy. It is counted separately from a miss. Rust executables, including test binaries and build scripts, are not cached by default on Windows; C/C++ flags and compiler modes also affect eligibility. Check current support and the relevant compiler guide.
For a Rust crate that misses, use its name from the report:
kache explain my_crate
Source, dependency, environment, toolchain, or option changes can produce a
new key. Explanation needs recorded key material; enable [cache] explain_miss
when collecting builds to compare. See cache keys
and build-script inputs.
Adaptive incremental mode can also compile a unit you are editing using its private incremental state. See Executables and incremental builds.
Native archives change on every clean build
If a crate that links a build-script-generated .a file keeps missing with
only the link key group changed, compare the archives from two clean builds.
The object code can be identical while the archive's member timestamps differ.
Kache includes those timestamps in the native-link key, so the Rust crate and
binaries that link it can miss too.
For a native Rust build using the cc crate and GNU ar, enable deterministic
archives before building. Check which archiver the build script invokes; an
explicit AR or target-specific setting can select a different tool from the
ar on PATH.
ar --version # Confirm this is GNU ar and the archiver your build uses.
HOST_ARFLAGS=D CARGO_INCREMENTAL=0 cargo build --release
GNU ar's D modifier
zeros archive member timestamps and normalizes ownership and modes. Some GNU
binutils builds enable it by default; others do not. ZERO_AR_DATE=1, which
helps on macOS, does not enable GNU ar's deterministic mode.
Some cc releases already request D automatically. Extra flags are useful
when the archive timestamps actually change, not when two archives already
match byte for byte.
HOST_ARFLAGS is a cc crate setting,
not a Kache setting. It applies when the build's host and target match. For a
cross-target build, configure the target's archiver flags instead, after
checking that archiver supports deterministic mode. Preserve any existing
archiver selection and required flags. Flag resolution depends on the cc
version locked by the project: some releases select a target-specific
ARFLAGS_<target> before HOST_ARFLAGS, while others combine the configured
flag variables. Check that version's configuration rules and remove any U
flag when requesting deterministic archives. Other build systems need their
own archiver configuration.
After changing the flags, rebuild the affected native library and compare two
clean builds with the same inputs. ar tv libexample.a shows member timestamps;
cmp first.a second.a checks whether the whole archives match. Deterministic
mode fixes archive metadata churn; it does not remove other differences such
as paths embedded in object files.
Miss details or old errors are missing from history
kache explain describes recorded builds. A historical SQL/schema error in a
skip record is evidence about that build, not a new database query failing now.
Since v2.0.0-rc.3, Kache rebuilds incompatible prediction metadata and keeps
compiled entries. Clearing the cache is unnecessary. Recognized prediction
failures recorded by older versions appear under "Earlier Kache bugs".
The report shows which Kache versions recorded the build. A failure recorded
by RC.3 or later still needs investigation. JSON retains the original error
and producer version for diagnosis.
Details missing or an unexplained cause means the retained event lacks the
inputs needed to compare keys. Enable recording before reproducing the build:
[cache]
explain_miss = true
You can also run kache config set cache.explain_miss true. Recording applies
to future events; it cannot reconstruct old key details or history already
rotated away. After rebuilding, compare kache explain --root "$PWD" with
kache explain --all --root "$PWD": the first selects the latest build, while
the second groups retained skips and passthroughs across build history.
Use kache doctor to check the current configuration and store before treating
an old report as a current failure.
A crate fails only with Kache
If one crate keeps failing with an error that goes away with
KACHE_DISABLED=1, the incremental state Kache keeps for it may be damaged.
Delete target/<profile>/incremental.kache-auto or run cargo clean.
cargo clean -p does not remove that directory, and
KACHE_ADAPTIVE_INCREMENTAL=0 only skips it until you turn the mode back on.
Cargo fix cannot write old metadata
Older Kache versions could leave read-only .rmeta files linked to cache blobs.
New restores use private writable files, but upgrading does not replace outputs
Cargo already considers fresh.
If cargo fix or cargo clippy --fix still reports a read-only metadata file,
finish any running builds, then remove the affected package's outputs and rebuild:
cargo clean -p <crate>
cargo check -p <crate>
Match the affected build's target and profile when cleaning, and use its feature options when rebuilding. This keeps the shared artifact cache; deleting that cache is unnecessary. The rebuild also reapplies current creation permissions to metadata restored by an older Kache. Retry the fix command after the rebuild.
Managed incremental state also starts fresh on each crate's next compilation after the managed state format changes to version 2. Older state expires through the usual unused-unit cleanup. Finish builds using the older Kache before upgrading so those processes cannot keep sharing incremental files with each other.
The remote is quiet
kache daemon status
kache doctor
kache stats
Compiler-driven remote reads and uploads need the daemon. Without it, local
caching and compilation continue. doctor tests the remote with this shell's
configuration and credentials, which can differ from the daemon's. kache stats
shows what the daemon uses: the remote it loaded or why it is misconfigured, and
a warning when it read a different config file than this shell. Its Resilience
row shows DEGRADED after three transport timeouts or transient remote errors in a row.
Builds then compile locally and uploads wait in the queue; the daemon tries the
remote again every 45 seconds until it answers.
Reaching Kache's operation deadline, including the configured synchronous demand lookup budget, returns a cache miss without changing remote health. Uploads that reach their deadline remain queued for retry.
Follow the remote setup guide for your backend, then check daemon lifecycle for service environment and configuration changes.
A read-only CI job can restore entries but cannot publish new work. Review
CI write policy before treating absent
uploads as a failure. kache sync --pull --dry-run can inspect explicit pull
discovery, but it needs listing permissions in addition to read access.
The cache uses more disk than expected
The storage guide explains the local budget, free-space recovery, shared blocks, target discovery, and cleanup previews.
kache stats reports registered blob bytes and the configured store budget.
It does not count every block occupied by target directories. Use:
kache clean --dry-run
This previews tracked target directories and what removing each can free.
Inside targets you still use, the daemon removes build units no build has read
for 30 days (auto_clean_unused_units_days). To trim obsolete units sooner,
record a successful build with KACHE_TARGET_LIVENESS=1 kache cargo check,
then preview kache clean --units target --dry-run. See
Recorded-command cleanup.
Read Deduplication before comparing logical sizes with allocated disk space, and Bounding storage for remote retention.
Share a useful report
kache stats --full --last-build --redact --format markdown --output kache-report.md
Review the file before sharing it. Include your OS, Kache and toolchain versions, build command, and the behavior you expected in a bug report. The command reference explains report windows and redaction.