From 518158f814708741be34a399a5f34b2aae591dc3 Mon Sep 17 00:00:00 2001 From: Robert M1 <50460704+githubrobbi@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:37:57 -0700 Subject: [PATCH] fix(toolchain): invalidate target/ + sccache after a nightly bump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit toolchain-sync probes candidate nightlies in a per-candidate scratch CARGO_TARGET_DIR, then commits the bump and exits without touching the main caches. Both retain the OLD nightly's artifacts, so the next build dies with E0514 'found crate X compiled by an incompatible version of rustc' (observed: assert_cmd/winnow/tempfile/toml_parser). Two caches must be invalidated, not one: 1. cargo clean — main target/ rlibs/rmeta carry the old rustc commit-hash; cargo fingerprints do not force a full rebuild across a nightly bump. 2. sccache --stop-server — the long-lived sccache daemon caches its compiler-version detection keyed by the rustc binary mtime/size. Under rustup, rustc is a toolchain-agnostic proxy (~/.cargo/bin/rustc -> rustup) whose bytes never change across a bump, so the daemon keeps serving the OLD nightly's objects and re-poisons target/ right after a cargo clean. Restarting forces a fresh rustc -vV probe. A full 30 GiB cache wipe is unnecessary. Both run only in the 'found newer nightly' success branch, not the 'no bump available' branch. --- just/shared.just | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/just/shared.just b/just/shared.just index 042f7102d..577554229 100644 --- a/just/shared.just +++ b/just/shared.just @@ -442,6 +442,31 @@ toolchain-sync: # Clean up any BSD-sed backup artifact from older broken invocations. rm -f "${TOOLCHAIN_FILE}-e" rustup default "$CANDIDATE" + + # ── Invalidate stale build caches after the bump ─────────── + # The probe loop above used a per-candidate scratch CARGO_TARGET_DIR, + # so the MAIN `target/` and the sccache daemon are still holding the + # OLD nightly's artifacts. Two distinct caches must be invalidated or + # the next build dies with E0514 "found crate X compiled by an + # incompatible version of rustc": + # 1. `cargo clean` — the main `target/` has rlibs/rmeta stamped with + # the OLD rustc commit-hash; cargo's fingerprint does not always + # force a rebuild across a nightly bump, so clear it outright. + # 2. `sccache --stop-server` — the long-lived sccache server caches + # its compiler-version detection keyed by the `rustc` binary's + # mtime/size. Under rustup, `rustc` is a toolchain-agnostic proxy + # (~/.cargo/bin/rustc -> rustup) whose bytes never change across a + # bump, so the running daemon keeps serving/storing objects under + # the OLD nightly's identity. Stopping the server forces a fresh + # `rustc -vV` probe on the next invocation, restoring correct + # cache keying. A full 30 GiB cache wipe is unnecessary — the + # daemon restart is the targeted fix. + printf "\033[0;34m Invalidating stale build caches (cargo clean + sccache restart)...\033[0m\n" + cargo clean 2>/dev/null || true + if command -v sccache >/dev/null 2>&1; then + sccache --stop-server >/dev/null 2>&1 || true + fi + printf "\033[0;32m✅ Toolchain synced to %s\033[0m\n" "$CANDIDATE" rustc --version cargo --version