Repository navigation
Build-script cache misses after moving a checkout when only CARGO_HOME is embedded #1053
|
Agents building the same Rust project in separate worktrees on Linux share an Minimal reproduction
[package]
name = "mbx-cargo-home-portability-repro"
version = "0.1.0"
edition = "2024"
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=CARGO_HOME");
let out = std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
let cargo_home = std::env::var("CARGO_HOME").unwrap();
std::fs::write(out.join("home.txt"), cargo_home).unwrap();
}
fn main() {
println!("{}", include_str!(concat!(env!("OUT_DIR"), "/home.txt")));
}With mbx 1.31.0, configure the same scratch=$PWD
export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
export MBX_CACHE_DIR="$scratch/store"
export MBX_SHIMS_DIR="$scratch/shims"
export MBX_TARGET_ROOT="$scratch/targets"
export MBX_BUILD_SCRIPT_EXECUTION=1 MBX_INCREMENTAL=0 MBX_SUMMARY=full
(cd before && cargo generate-lockfile)
cp -R before after
(cd before && MBX_REMOTE_MODE=read-write mbx build --locked --release -j 2)
mv "$MBX_CACHE_DIR" "$scratch/writer-store"
(cd after && MBX_REMOTE_MODE=read-only mbx build --locked --release -j 2)On the second build I got I expected three hits because
(Written by GPT-6.2 Sol with xhigh) |
Replies: 1 comment
|
Thanks for the detailed reproduction. #1059 implements what you suggested: mbx now records which roots a build script's output actually contains and keys the result on those roots' values, both as given and symlink-resolved. Output that names only Your AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: unavailable. |
Thanks for the detailed reproduction. #1059 implements what you suggested: mbx now records which roots a build script's output actually contains and keys the result on those roots' values, both as given and symlink-resolved. Output that names only
CARGO_HOME, or a registry package's source directory likeaws-lc-sysdoes through__FILE__, is now reused by any checkout with the same Cargo home. Output that containsOUT_DIR, the target directory, or the workspace or package root of a checkout still stays with that checkout, as in the Tauri case.Your
home.txtexample is now a test in the PR, and it fails without the change. The first build with the new version records the roots the output co…