If I install rustup with the standard flow from https://rustup.rs/, and then uninstall it with rustup self uninstall, my entire ~/.cargo directory gets deleted. This happens even if I have a lot of binaries in there installed by my system's version of Cargo, from before I started using rustup. Is that intended? I think rustup should uninstall the shims that it put in ~/.cargo/bin, but not assume it owns the entire directory.
I should point out that if curl https://sh.rustup.rs -sSf | sh is ran in your HOME or ~ directory when you run rustup self uninstall it will nuke your entire home directory and ALL contents.
This just happened to me.
cc: @brson
@valarauca Did you override CARGO_HOME to be your entire home directory? Doing what you described is the normal way to install and will not nuke your home dir.
@Diggsey I never touched my CARGO_HOME variable. I just copy and pasted the install command from the web. One thing I noticed was rustup placed it bin directory at my ~ instead of my ~/.cargo Initially when I attempted to install I was told rustup couldn't because rust was installed. So I cd'd to remove it. I re-ran the rustup install command in my /usr/local/lib/rustlib which gave me an error about CARGO_HOME being undefined. So I attempted to export it to ~/.cargo.
This failed as my ~/.cargo didn't exist. So I cd'd back to home, and ran the installer.
@valarauca Is it possible that CARGO_HOME was set to an empty string, rather than being unset? There was a bug where an empty CARGO_HOME would be resolved relative the current directory, rather than being treated as if it was unset and using the default value instead.
If this was the issue, I've fixed it in the latest release of rustup, so this can be closed.
@Diggsey I beleve this is correct.
But that doesn't solve the core issue that Rustup is deleting the directory _above_ it's installation files, not the files it created itself. No matter what they file/directory is.
@valarauca Rustup creates the cargo directory on install, so it makes sense to remove it on uninstall.
My worry is that Rustup isn't the only program that creates this directory. For a more extreme example, many programs will create ~/.config, but that doesn't mean they can delete it.
@oconnor663: Though I think you鈥檙e right, note that before proceeding rustup shows this warning and confirmation prompt:
Thanks for hacking in Rust!
This will uninstall all Rust toolchains and data, and remove
/home/myuser/.cargo/bin//bin from your PATH environment variable.
@Diggsey: what about making explicit what directories are going to be recursively removed? If it's the home dir, the programmer could avoid a catastrophe.
Most helpful comment
My worry is that Rustup isn't the only program that creates this directory. For a more extreme example, many programs will create
~/.config, but that doesn't mean they can delete it.