"rustup self uninstall" causes data loss, leaves behind only cargo binaries
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 22h 40m
- Merged PRs (30d)
- 46
Description
I just had a bizzare experience with rustup - unfortunately, one that lost me quite a few hours of work (which would have been many times more, without a backup).
Here's a rough sketch of what happened, as far as I can tell:
-
Install "stable" and "nightly" using rustup
-
rustup self update, to ensure newest
-
Update "stable" and "nightly" again, to ensure newest
-
I had a problem where ~/.cargo/bin was added to my ~/.zshrc, which gave me $PATH inclusion for the commands in interactive shells. However, I have some build scripts for various things that like to call cargo or rust as well, and these fail, since they're not running under interactive shells.
-
On my workstation, I have ~/bin in the default path, to allow users to install local binaries. This solves the problem, as long as cargo and rustc are symlinked to ~/bin.
-
To make it "just work", I symlinked ~/.cargo/bin to ~/bin, so rustup would effectively install in ~/bin.
Since I had some more problems, I finally decided to try the following commands:
$ rustup toolchain uninstall stable
$ rustup toolchain uninstall nightly
$ rustup self uninstall
To my shock, I see that my ~/bin folder has been all but completely destroyed. To provide some salt for the wound, the only files NOT removed, are the rustup ones:
$ ls -l ~/bin
total 67740
-rwxrwxr-x 1 chrivers chrivers 10649744 Apr 17 22:41 cargo
-rwxr-xr-x 6 chrivers chrivers 9785208 Apr 17 22:13 rls
-rwxr-xr-x 6 chrivers chrivers 9785208 Apr 17 22:13 rustc
-rwxr-xr-x 6 chrivers chrivers 9785208 Apr 17 22:13 rustdoc
-rwxr-xr-x 6 chrivers chrivers 9785208 Apr 17 22:13 rust-gdb
-rwxr-xr-x 6 chrivers chrivers 9785208 Apr 17 22:13 rust-lldb
-rwxr-xr-x 6 chrivers chrivers 9785208 Apr 17 22:13 rustup
Whiskey Tango Foxtrot.
The dirs .cargo and .rustup are gone, as are all my binaries and shell scripts. This is a pretty catastrophic result.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the rustup self uninstall entry point and reproduce the reported sequence with a symlinked ~/.cargo/bin. Trace which paths the uninstall operation removes, then add coverage for preserving files outside rustup's managed installation; done means the command no longer deletes unrelated files in ~/bin.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100