Skip to content

rustup self remove should not remove ~/.cargo/bin files that it doesn't own #4644

Closed as duplicate

Description

@Wilfred

Verification

Problem

rustup removes the entirety of ~/.cargo/bin. This is frustrating when you've done a few cargo install foo and want to keep the binaries.

I run rustup self remove sometimes when I want to be sure that I'm testing the system rustc version, and it surprised me to lose a bunch of rust binaries that I'd installed.

Steps

  1. Install rustup
  2. cargo install bat
  3. rustup self remove
  4. ls ~/.cargo/bin

Possible Solution(s)

I suggest that rustup only removes the symlinks in ~/.cargo/bin that it originally created. These should be easy to detect.

$ ls -lh ~/.cargo/bin
-rwxr-xr-x  1 wilfred  staff   5.6M  3 Dec 10:27 bat*
lrwxr-xr-x  1 wilfred  staff     6B 28 Aug 12:27 cargo@ -> rustup
lrwxr-xr-x  1 wilfred  staff     6B 28 Aug 12:27 cargo-clippy@ -> rustup
...

Notes

No response

Rustup version

$ rustup --version
rustup 1.28.2 (e4f3ad6f8 2025-04-28)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.92.0 (ded5c06cf 2025-12-08)`

Installed toolchains

$ rustup show
Default host: aarch64-apple-darwin
rustup home:  /Users/wilfred/.rustup

installed toolchains
--------------------
stable-aarch64-apple-darwin (active, default)
1.74.1-aarch64-apple-darwin
1.75.0-aarch64-apple-darwin
1.76.0-aarch64-apple-darwin

active toolchain
----------------
name: stable-aarch64-apple-darwin
active because: it's the default toolchain
installed targets:
  aarch64-apple-darwin

OS version

$ uname -a
Darwin wilfred-mac 25.1.0 Darwin Kernel Version 25.1.0: Mon Oct 20 19:34:05 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6041 arm64

Activity

  1. rami3l commented on Dec 15, 2025

    @rami3l
    Member

    @Wilfred rustup self remove is meant to remove the whole rust installation from your machine and the current assumption is that rustup fully owns ~/.cargo/bin, so I'd say this is working as intended.

    The option of removing only the links has already been considered as a part of #247's solution, and the consensus that our team had with the cargo team was that it can be implemented on another directory other than ~/.cargo/bin, say ~/.local/bin (cc @epage).

    For your particular use case, I'd suggest linking the system toolchain as described in https://rust-lang.github.io/rustup/installation/already-installed-rust.html#set-up-rustup-with-an-existing-rust-toolchain.

  2. ChrisDenton commented on Dec 15, 2025

    @ChrisDenton
    Member

    We do plan to change this as part of the work to support xdg directories in cargo and rustup

  3. epage commented on Dec 15, 2025

    @epage
    Contributor

    For notes on the XDG plans, see https://blog.rust-lang.org/inside-rust/2025/10/01/this-development-cycle-in-cargo-1.90/#all-hands-xdg-paths

    This issue looks to mostly be a duplicate of #285, see also #285 (comment)

  4. rami3l commented on Dec 15, 2025

    @rami3l
    Member

    @epage Nice call! Closing…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions