From 8a04f1aa7232c1c19b0e91438c615809309425b1 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 10 Feb 2026 10:17:56 -0600 Subject: [PATCH] fix(script): Make the lockfile script-specific independent of build-dir Before if users decide to use a shared `build-dir`, they would also get a shared lockfile with their cargo scripts, causing them to constantly change dependencies and rebuild. This includes a workspace path hash in the lockfile path inside of the `build-dir` so it is unique independent of what `build-dir` gets set to. --- src/cargo/core/workspace.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 9a19585428c..bdf06d60757 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -740,7 +740,13 @@ impl<'gctx> Workspace<'gctx> { fn default_lock_root(&self) -> Filesystem { if self.root_maybe().is_embedded() { - self.build_dir() + // Include a workspace hash in case the user requests a shared build-dir so that + // scripts don't fight over the `Cargo.lock` content + let workspace_manifest_path = self.root_manifest(); + let real_path = std::fs::canonicalize(workspace_manifest_path) + .unwrap_or_else(|_err| workspace_manifest_path.to_owned()); + let hash = crate::util::hex::short_hash(&real_path); + self.build_dir().join(hash) } else { Filesystem::new(self.root().to_owned()) }