Repository navigation
Description
Frame version
0.34.0, built from source at 66HEX/frame 8fe5aa1
Operating system
Windows
Operating system version
Windows 11, 10.0.26200.9711
Source media details
git clone of https://github.com/66HEX/frame, built from source; Inno Setup 6.7.1 installed machine-wide via Chocolatey; rustc/cargo 1.95.0 with the toolchain pinned by rust-toolchain.toml
Steps to reproduce
- Clone the repo and confirm
rustup target add x86_64-pc-windows-msvcsucceeds. - Install Inno Setup 6.
- Run
cargo xtask bundle windows.
Expected behavior
The Windows installer is built at target\Frame-x86_64.exe.
Actual behavior
The command fails before packaging, on every attempt (2 of 2 here):
error: failed to remove file `C:\...\frame\target\debug\xtask.exe`
Caused by:
Access is denied. (os error 5)
cargo exited with status 101
Running the underlying script directly succeeds and produces target\Frame-x86_64.exe:
powershell -NoProfile -ExecutionPolicy Bypass -File .\script\bundle-windows.ps1
Details
The bundle path re-enters cargo while the xtask process that spawned it is still running:
.cargo/config.tomlaliasesxtasktorun --package xtask --, so cargo builds and startstarget\debug\xtask.exe.bundle("windows")(tooling/xtask/src/main.rs:185) spawnsscript/bundle-windows.ps1throughrun_script(:1690) andrun_command(:1714).run_commandusesCommand::status()with inherited stdio, so it blocks until the script exits, and thextask.exeimage stays mapped the whole time.script/bundle-windows.ps1:123runscargo xtask setup-ffmpeg ..., a nested cargo build in the same target directory. It decidesxtaskmust be relinked, but Windows will not replace a running image, hence os error 5.
Why the nested build is always dirty: cargo run injects CARGO_MANIFEST_DIR, CARGO_MANIFEST_PATH and CARGO_PKG_* into the process it starts. Verified with a minimal binary: under cargo run those variables are set to the crate's own values; the same exe run directly has them unset.
ring's build script declares cargo:rerun-if-env-changed=CARGO_MANIFEST_DIR itself (ring-0.17.14/build.rs:38, read at :272). Cargo records the value from its own process environment, not from the build script's environment: the script always sees its own crate directory (ring's build.rs calls .expect("CARGO_MANIFEST_DIR should always be set")), yet the stored fingerprint value is null in a plain-shell build.
The two contexts therefore disagree, with this trace from the nested case:
dirty: EnvVarChanged { name: "CARGO_MANIFEST_DIR",
old_value: None,
new_value: Some("C:\\Users\\Eliot\\Applications\\frame\\tooling\\xtask") }
(CARGO_LOG=cargo::core::compiler::fingerprint=trace with that variable exported; the following plain build reports the reverse, Some -> None.) Each attempt flips the recorded value, so one of the two contexts is always dirty and re-running cannot get further. In the failing logs the rebuild covers ring, rustls, rustls-webpki, tokio-rustls, ureq, hyper-rustls, reqwest, frame-updater, and finally xtask, whose relink fails.
Minimal reproduction without ring, in a crate whose build.rs only prints cargo:rerun-if-env-changed=CARGO_MANIFEST_DIR:
cargo build(first): compilescargo build(again): cleanCARGO_MANIFEST_DIR=<any path> cargo build: compilescargo build(plain again): compiles
The same recursion exists on the other platforms: script/bundle-linux:110 and script/bundle-mac:77 also call cargo xtask setup-ffmpeg. On Unix a running binary can be replaced, so the expected cost there is rebuild time instead of a hard failure (reasoning; not tested on a Unix host).
This is the documented release path (README.md:305-317, CONTRIBUTING.md:194-196, frame-app/README.md:24). CI does not hit it because the workflows call the scripts directly (release.yml:446, run_bundling.yml), so the failure is invisible there.
The direct-script workaround works because no xtask.exe image is mapped when the nested cargo run builds and runs it, which is also the control experiment for this diagnosis.
Suggested fix
- Run
setup-ffmpeginside xtask before spawning the script, then pass a flag so the script skips its owncargo xtask setup-ffmpegstep. The script's remaining cargo calls build release binaries for the target triple, not host xtask, so no running image is relinked. Note that.github/workflowsare generated (cargo xtask workflows), so CI-side changes belong in the generator. - Alternatively, have the script call
target\debug\xtask.exe setup-ffmpeg ..., but only as a fast path with acargo run --package xtask --fallback: CI and the documented script path start from a bare checkout where that binary does not exist, and a stale binary would silently run old code. - As a mitigation, scrub
CARGO_MANIFEST_DIR,CARGO_MANIFEST_PATHandCARGO_PKG_*when spawning the script. That removes this flip but not environment changes the script makes itself (the dev shell import sets variables ring also tracks), so it is not sufficient alone.
Activity
fix(xtask): stop the Windows bundle script from re-entering cargo
fix(xtask): stop the Windows bundle script from re-entering cargo
fix(xtask): stop the Windows bundle script from re-entering cargo (66…