rust-lang / rustup

The Rust toolchain installer
https://rust-lang.github.io/rustup/
Apache License 2.0
6.1k stars 877 forks source link

`rustup self uninstall` fails on Windows if a custom toolchain is installed #2789

Open jyn514 opened 3 years ago

jyn514 commented 3 years ago

Problem Rustup gives a "permission denied" error if you try to uninstall it after linking a custom toolchain.

Steps

$ git clone https://github.com/rust-lang/rust
$ cd rust
$ cargo install --path src/tools/x
$ echo 'profile = "tools"' > config.toml
$ x build
$ rustup toolchain link stage2 build/x86_64-pc-windows-msvc/stage2
$ rustup self uninstall

Thanks for hacking in Rust!

This will uninstall all Rust toolchains and data, and remove
%USERPROFILE%\.cargo/bin from your PATH environment variable.

Continue? (y/N) y

info: removing rustup home
error: could not remove 'rustup_home' directory: 'C:\Users\Joshua Nelson\.rustup': Access is denied. (os error 5)

The only thing left in ~/.rustup is .rustup/toolchains/stage2/.

Notes

Output of rustup --version: rustup 1.24.2 (755e2b07e 2021-05-12) Output of rustup show:

Default host: x86_64-pc-windows-msvc
rustup home:  C:\Users\Joshua Nelson\.rustup

no active toolchain
rbtcollins commented 3 years ago

Probably the recursive delete crate we use doesn't know how to remove a reparse point.

kinnison commented 3 years ago

Could we essentially do a "for each installed toolchain, uninstall toolchain, then uninstall self` in the uninstallation pathway?

It'd be a tad more long-winded than our current approach, but it would result in things being more predictable perhaps?

Darunada commented 2 years ago

I went with your suggested approach, let me know what you think, thanks!

abc598300612 commented 2 years ago

Probably the rust was still being used. I had the same issue When I uninstalled rust on windows. Finally,I resolved by killing rust in task manager.