Repository navigation
fix(xtask): stop the Windows bundle script from re-entering cargo - #256
Merged
Merged
Conversation
CSEliot
force-pushed
the
fix/xtask-bundle-windows-reentry
branch
from
November 14, 2026 13:46
1374932 to
a426f32
Compare
`cargo xtask bundle windows` spawned script/bundle-windows.ps1 while the xtask process was still mapped, and the script re-entered cargo through `cargo xtask setup-ffmpeg`. `cargo run` exports package variables into the child, so the nested build recorded a different CARGO_MANIFEST_DIR for ring, rebuilt the TLS stack, and tried to relink the running xtask.exe, which Windows rejects with `Access is denied` (os error 5). Run setup_ffmpeg inside xtask before spawning the script, forward -SkipSetupFfmpeg so the script does not re-enter cargo, and strip the cargo run package environment from child processes so cargo builds inside the script match a plain-shell invocation. setup_ffmpeg is skipped for -Help, -PackageOnly, an explicit -SkipSetupFfmpeg and any architecture other than x86_64, so those paths keep their existing diagnostics without touching the binary cache. Direct script runs and CI keep their current behavior because the switch defaults to off. Fixes 66HEX#254.
CSEliot
force-pushed
the
fix/xtask-bundle-windows-reentry
branch
from
November 14, 2026 14:52
a426f32 to
2435533
Compare
66HEX
approved these changes
Nov 21, 2026
66HEX
left a comment
Owner
There was a problem hiding this comment.
Thanks for the thorough diagnosis and clean fix! The in-process setup_ffmpeg handling, env scrubbing, and unit tests all look solid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #254.
cargo xtask bundle windowscould not complete on Windows. The bundle command spawnsscript/bundle-windows.ps1while thextask.exeimage is still running, and the script's first cargo step re-enters cargo withcargo xtask setup-ffmpeg.cargo runexportsCARGO_MANIFEST_DIRand the other package variables into the child;ringfingerprintsCARGO_MANIFEST_DIRthroughcargo:rerun-if-env-changed, so the nested build saw a different value, rebuilt the TLS stack, and tried to relink the runningxtask.exe. Windows rejects that withfailed to remove file ... Access is denied (os error 5).Changes
tooling/xtask/src/main.rsbundle windowsrunssetup_ffmpegin-process before spawning the script and forwards-SkipSetupFfmpeg. Setup is skipped for-Help,-PackageOnly, an explicit-SkipSetupFfmpeg, and any-Architecture/-avalue other thanx86_64(space-separated,-Architecture:value, and a dangling switch included), so those invocations reach the script's own diagnostic without touching the binary cache. A non-Windows host gets the existing Windows-only usage error before any download.run_commandstrips thecargo runpackage environment (CARGO_MANIFEST_DIR,CARGO_MANIFEST_PATH,CARGO_PKG_*) from child processes, so cargo builds inside the script fingerprint the same as a plain-shell run. Without that, the documented command and a direct script run would keep invalidating each other's fingerprints, including a full release-profile rebuild.script/bundle-windows.ps1-SkipSetupFfmpegswitch, documented in-Help, with an early existence check for both runtime binaries. The runtime binary paths are now resolved by one helper shared withPrepare-BundleDirectory.cargo xtask setup-ffmpeg, which is how CI and direct script runs invoke it.Testing
cargo xtask bundle windowscompletes end to end on Windows 11 (rustc/cargo 1.95.0, Inno Setup 6.7.1): exit 0,Successful compile (108.359 sec),target/Frame-x86_64.exewritten. The log shows the script launched with-SkipSetupFfmpegand no nestedcargo xtask.-Help,-Architecture arm64,-Architecture:arm64, and a dangling-Architectureall reach their diagnostics with noDetected Windows ... Preparing FFmpegline.script/bundle-windows.ps1 -Architecture x86_64 -PrepareOnlystill runscargo xtask setup-ffmpeg, stages the same inputs, and exits 0.cargo fmt --manifest-path tooling/xtask/Cargo.toml --checkpasses; the five new unit tests pass.cargo clippy --all-targets -- -D warnings. A bare run on Windows still fails on pre-existing lints only (frame-updaterdead code and the non-Unixmake_file_executablevariant, both present on8fe5aa1); with those allowed, clippy exits 0. The full xtask test suite has four pre-existing failures on this CRLF checkout (workflow/dependabot string assertions and bash-mock tests), also present on8fe5aa1.CARGO_MANIFEST_DIRentry isnullintarget/x86_64-pc-windows-msvc/release, i.e. the scrubbed child build matches a plain-shell invocation. Thetarget/debugentry is also null, but that build came from a plain-shell invocation, so it says nothing about the bundle path.Notes
.github/workflowsis generated bycargo xtask workflowsand untouched.bundle-linuxandbundle-macstill callcargo xtask setup-ffmpeg, but the env scrub means that nested build no longer sees a spurious environment difference; on Unix a running binary can be replaced, so the failure mode there is only wasted rebuild time.