Skip to content

fix(windows/uninstall-gc): Run Windows uninstall GC from the system temporary directory - #5090

Draft
Cloud0310 wants to merge 7 commits into
rust-lang:mainfrom
Cloud0310:windows-uninstall-gc
Draft

Cloud0310 wants to merge 7 commits into
rust-lang:mainfrom
Cloud0310:windows-uninstall-gc

Conversation

@Cloud0310

Copy link
Copy Markdown
Contributor

Proceeding of #5088
This PR does:

  • Run Windows uninstall GC from the system temporary directory, removing the requirement for write access to the parent of CARGO_HOME.
  • Use tempfile to manage the GC file and copy the running executable’s contents into it. This creates an independent executable instead of reproducing a source symlink and avoids relying on the installed rustup copy.
  • Use fs::copy and utils::current_exe for copying gc program, allowing for potential copying dead symlink and being less dependent upon fixed binary path (~/.cargo/bin/rustup.exe).

@rami3l

rami3l commented Sep 16, 2026

Copy link
Copy Markdown
Member

@Cloud0310 When stacking a PR on top of another, you should keep the top PRs as draft and wait for the prerequisites to be merged first.

@rami3l
rami3l marked this pull request as draft September 16, 2026 18:28
Use OpenOptions and inherited stdin to manage the GC handle with standard file APIs. Keep Command alive through the existing sleep to retain the handle.
Inline the single-use ensure_empty helper and replace GcErr with an inline error. Preserve the existing directory and GC filename filter.
Attempt the existing GC self-cleanup even if waiting for the parent or removing cargo-home state fails. Preserve the original uninstall error when starting cleanup also fails; report the cleanup error when uninstalling succeeded.
Use tempfile to manage the GC path until the delete-on-close handle takes
over cleanup.
Copy the executable contents into a regular temporary file so delete-on-close
removes the GC copy instead of a symlink target. Close the write handle before
opening the executable for reading.
Copy the running executable so GC does not depend on the installed
rustup copy.
Create GC in the system temporary directory to avoid requiring write access
to the parent of CARGO_HOME. Update the cleanup test to use an isolated
temporary directory.
@rustbot

rustbot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #5091) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants