Skip to content

fix(#1801): keep each checkout's isolated build in its own target/ - #1825

Merged
enricopiovesan merged 1 commit into
mainfrom
fix/1801-checkout-local-target-dir
Nov 7, 2026
Merged

enricopiovesan merged 1 commit into
mainfrom
fix/1801-checkout-local-target-dir

Conversation

@enricopiovesan

Copy link
Copy Markdown
Collaborator

Follow-up to #1801 (fixed in #1803).

Summary

#1803 gave each checkout its own Cargo target directory when CARGO_TARGET_DIR points outside it, so local checks never run binaries another checkout built. It put that directory at ${CARGO_TARGET_DIR}/checkouts/<id>, which nothing ever removes. Each one is a full build of 5–22 GB (debug, release, llvm-cov-target, iOS and wasm targets). Claude Code sessions create many short-lived worktrees, so these folders pile up. On 2026-11-05/06, nine of them filled about 160 GB of disk in roughly 24 hours, and three belonged to worktrees that no longer existed.

checkout_target_dir.sh now points an outside CARGO_TARGET_DIR at <checkout root>/target instead. That folder is git-ignored (target/ in .gitignore), and deleting the worktree deletes it too.

  • Local checks can test another checkout when CARGO_TARGET_DIR is shared #1801 still holds: no two checkouts ever share a target directory, because each one builds inside its own root.
  • A CARGO_TARGET_DIR that is unset stays unset, so Cargo uses target/ as before.
  • A directory already inside the checkout is kept, and so is a relative one.
  • Sourcing the helper twice gives the same result.
  • The checkout ID hash is gone because nothing uses it now.

What this costs: a checkout no longer keeps its build under the developer's chosen shared location. That folder was never shared between checkouts anyway, so builds are no less incremental than before.

Governing Spec

  • 004-spec-alignment-gate
  • 075-native-runtime-distribution-contract

Project Item

Validation

  • scripts/ci/checkout_target_dir_test.sh now asserts that each checkout resolves to its own target/ and that one checkout's target/ is never used by another. It fails against the previous helper (.../shared/checkouts/9c89c4bf1b954c13).
  • Sourced under bash in this worktree with CARGO_TARGET_DIR=~/.cargo-target-shared, the helper resolves to <worktree>/target, and sourcing it again gives the same path.
  • scripts/ci/repository_checks.sh passes.
  • Full local_preflight.sh --pr-body passed with the shared CARGO_TARGET_DIR set. The build (19 GB) went into this worktree's target/. The script skipped native artifact certification because this machine lacks Java, .NET and the Android SDK, and it always skips the hosted-only CodeQL and stress jobs.

🤖 Generated with Claude Code

checkout_target_dir.sh moved an outside CARGO_TARGET_DIR to
<dir>/checkouts/<id>. Those 5-22 GB builds outlived their worktrees: nine
of them filled ~160 GB in a day, three for deleted worktrees. The helper
now points it at the checkout's git-ignored target/, so the build is
removed with the checkout and is still never shared between checkouts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@enricopiovesan
enricopiovesan enabled auto-merge (squash) November 6, 2026 22:24
@enricopiovesan
enricopiovesan merged commit 9e52068 into main Nov 7, 2026
50 of 54 checks passed
@enricopiovesan
enricopiovesan deleted the fix/1801-checkout-local-target-dir branch November 7, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant