:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(dev): build each worktree into its own rust/target (#128930)
Robbief7bf6c93368f
diff --git a/.flox/env/on-activate.sh b/.flox/env/on-activate.shindex 325c73329e82..6e785b0dbac4 100755--- a/.flox/env/on-activate.sh+++ b/.flox/env/on-activate.sh@@ -515,9 +515,6 @@ if [[ "$(uname -s)-$(uname -m)" == "Darwin-arm64" && -z "${SDKROOT:-}" ]] && comunset -f _sdk_lld_can_linkfi-# Share a single Cargo target dir so worktrees skip redundant linking-export CARGO_TARGET_DIR="$HOME/.cargo/target"-# ── Summary ─────────────────────────────────────────────────────────_activation_end=$(date +%s)_activation_time=$(( _activation_end - _activation_start ))diff --git a/tools/hogli-commands/hogli_commands/doctor.py b/tools/hogli-commands/hogli_commands/doctor.pyindex 6497d9c42527..1759d001e2ea 100644--- a/tools/hogli-commands/hogli_commands/doctor.py+++ b/tools/hogli-commands/hogli_commands/doctor.py@@ -280,8 +280,8 @@ def doctor_disk(title="🦀 Rust Cargo targets",description=["Runs 'cargo clean' in all Rust workspaces to remove build artifacts.",- "The Flox env sets CARGO_TARGET_DIR, so the artifacts sit outside the repo",- "and every worktree shares one target directory.",+ "Each worktree builds into its own rust/target, so this cleans only the current worktree.",+ "A CARGO_TARGET_DIR set in your shell is cleaned too.",],estimate=_estimate_rust_targets,cleanup=_cleanup_rust,@@ -636,7 +636,7 @@ def _estimate_rust_targets(repo_root: Path) -> CleanupEstimate:external = _cargo_target_dir()if external is not None:- details.append(f" CARGO_TARGET_DIR is {external}, shared by every worktree.")+ details.append(f" CARGO_TARGET_DIR is {external}, shared by every checkout that builds with it set.")if items:details.append(f" Total target directory size: {_format_size(total)}")@@ -1360,7 +1360,7 @@ def _collect_paths_from_patterns(repo_root: Path, patterns: Sequence[str]) -> lidef _cargo_target_dir() -> Path | None:- """The shared target directory `.flox/env/on-activate.sh` points Cargo at, if set."""+ """The target directory the shell points Cargo at with CARGO_TARGET_DIR, if set."""configured = os.environ.get("CARGO_TARGET_DIR")return Path(configured).expanduser() if configured else Nonediff --git a/tools/hogli-commands/hogli_commands/tests/test_doctor.py b/tools/hogli-commands/hogli_commands/tests/test_doctor.pyindex b717c35936fc..f3bac1d4ee7a 100644--- a/tools/hogli-commands/hogli_commands/tests/test_doctor.py+++ b/tools/hogli-commands/hogli_commands/tests/test_doctor.py@@ -2013,8 +2013,7 @@ def test_estimate_sccache_accepts_a_directory_of_its_own(monkeypatch: pytest.Mondef test_collect_rust_target_dirs_includes_the_shared_cargo_target_dir(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:- # The Flox env points CARGO_TARGET_DIR outside the checkout, so a repo-only- # scan reports the Rust artifacts as empty while they hold tens of GB.+ # A CARGO_TARGET_DIR outside the checkout holds the Rust artifacts, so a repo-only scan reports them as empty.repo = tmp_path / "repo"repo.mkdir()shared_target = tmp_path / "cargo-target"