Cannot uninstall Rust ("rustup self uninstall" command fails)

Hello from Japan :wave: (I am sorry for my poor English.)

I'm trying to install Rust on my Windows 10 PC.
I wanted to install Rust in the folder C:\dev\rust,
so I followed this rustup documentation to configure the install folder.

But I accidentally set environment variables:
CARGO_HOME = "C:\dev\rust"
RUSTUP_HOME = "C:\dev\rust"
instead of:
CARGO_HOME = "C:\dev\rust\.cargo"
RUSTUP_HOME = "C:\dev\rust\.rustup"

then I ran rustup-init.exe and it seemed that the installation had succeeded.

I realized my mistakes after the installation and tried to uninstall Rust by rustup self uninstall, but this error happens:

PS C:\dev> rustup self uninstall

Thanks for hacking in Rust!

This will uninstall all Rust toolchains and data, and remove
C:\dev\rust/bin from your PATH environment variable.

Continue? (y/N) y

info: removing rustup home
error: could not remove 'rustup_home' directory: 'C:\dev\rust': access denied (os error 5)

I'm only using administrator account and PowerShell is run as administrator.
Strangely enough, all files and folders in C:\dev\rust are deleted except for C:\dev\rust\bin.
How can I uninstall properly?

You can just delete the left overs manually. Rustup is pretty self-contained so there's not much to uninstall other than removing the files and modifying the PATH environment variable.

1 Like

It worked fine! Thank you :blush:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.