fix(build-script): run build scripts after CI restores target/ at another path #1046
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.57) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #1046"
general
weight: 0.35
jdx
A CI job that restores
target/at a different checkout path than the job that saved it failed as soon as Cargo reran a build script it did not recompile:mbx now repairs the build-script launchers of a moved target directory it does not manage, so that build succeeds. This affects Unix. A fork, a renamed repository, or a cache shared between jobs that check out at different paths all restore
target/at a new path. It was hit in CI jobs that mounted atarget/saved by jobs with another checkout path, whereaws-lc-sysfailed this way.What went wrong
After compiling a build script, mbx replaces Cargo's executable with a small launcher and keeps the real program beside it. When the path is short enough for a shebang, the launcher is one line naming mbx by absolute path:
Restore that
target/under another checkout path and the file is still there, but its interpreter is not, soexecvereportsENOENTfor a file that exists. That is Cargo's "(never executed) / No such file or directory".mbx already rewrote the launchers of a profile that had moved, but only for a target directory it manages. In CI it builds into the
target/the job's cache step restored and leaves it unmanaged, so the repair never ran in the one place atarget/routinely arrives from another path.Cargo runs the stale launcher when a build script's run is out of date while its compilation is not. For
cc-using dependencies such asaws-lc-sysandzstd-systhat happens on every such job when the mbx binary lives inside the checkout: mbx setsHOST_CCto a shim directory named for the mbx binary's own path, and those build scripts declarererun-if-env-changed=HOST_CC.The fix
When mbx does not place the target directory, it now runs the same repair on the directory Cargo will build into (the build directory when Cargo keeps one apart from the target directory). A profile that has not moved costs one small read of its
.mbx-launcher-rootmarker, as before.Both this repair and the existing one for a managed target now read the profile from the alias-expanded command. The repair waits for Cargo's lock only on the profile the command builds, so with an alias such as
ci-build = "build --release"it used to wait ondebugand could skip areleaseprofile that another Cargo held at that moment.Validation
a_ci_target_restored_at_another_path_still_runs_its_build_scriptsincrates/mbx/tests/build.rs: builds underCI=trueinto an existingtarget/, renames the checkout, and builds again with an empty store and the build script's rerun trigger changed. It failed with the "(never executed)" error before the fix and passes with it.zstd-sys, with the mbx binary inside the checkout and no explicit trigger. Released mbx 1.31.0 fails the second build after the move with the error at the top; with this change the build finishes, and the launchers and the marker name the new path.cargo test -p mbx --test buildandcargo test -p mbx --libpass on Linux. Not run on macOS.AI-assisted — Tool: Claude Code; model: anthropic/claude-fable-5-2; version: 2.1.332.
🤖 Generated with Claude Code
<!-- CURSOR_SUMMARY -->
---
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
On Unix, launchers are repaired when managed target placement is unavailable, using the selected build profile’s directories. If no separate build directory is resolved, the target directory is used.
Launcher repairs now account for effective profiles selected through Cargo aliases.
Builds restored from a different checkout path no longer leave launchers pointing to the original location, helping projects work after build artifacts are moved.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->