rust-lang / rust-lang/rustup

"rustup self uninstall" causes data loss, leaves behind only cargo binaries

Open
#1,072 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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:

  1. Install "stable" and "nightly" using rustup

  2. rustup self update, to ensure newest

  3. Update "stable" and "nightly" again, to ensure newest

  4. 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.

  5. 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.

  6. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.