Description
Verification
- I searched for recent similar issues at https://github.com/rust-lang/rustup/issues?q=is%3Aissue+is%3Aopen%2Cclosed and found no duplicates.
- I am on the latest version of Rustup according to https://github.com/rust-lang/rustup/tags and am still able to reproduce my issue.
Problem
A rustup toolchain uninstall <toolchain>
invocation reports that the <toolchain>
has been uninstalled even if there is no such toolchain present in the first place.
Steps
- Install rustup.
- Run
rustup toolchain uninstall <toolchain>
with literally anything in place of<toolchain>
, "foo", 42, the smiley emoji (😄). - Observe the output
rustup toolchain uninstall 😄 info: no toolchain installed for '😄' info: toolchain '😄' uninstalled
Even though rustup recognizes that there is no such toolchain, it still reports that it has been uninstalled.
Now it's of course not a big issue in a silly example like above, but gives the false impression of removing an actual toolchain without doing so. For example,
> rustup toolchain install 1.70.0
> rustup toolchain list
Which shows
stable-x86_64-unknown-linux-gnu (default)
1.70.0-x86_64-unknown-linux-gnu
So naturally you run rustup toolchain uninstall 1.70.0-x86_64-unknown-linux-gnu
and you get
info: no toolchain installed for '1.70.0-x86_64-unkown-linux-gnu'
info: toolchain '1.70.0-x86_64-unkown-linux-gnu' uninstalled
If you're not careful while reading, and miss that "no," looks like the toolchain has indeed been removed.
Possible Solution(s)
This unconditional check for the non-existence of the path even after possibly finding that the toolchain doesn't exist may be the root cause.
Notes
No response
Rustup version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.78.0 (9b00956e5 2024-04-29)`
Installed toolchains
Default host: x86_64-unknown-linux-gnu
rustup home: /home/scimas/.rustup
installed targets for active toolchain
--------------------------------------
aarch64-unknown-linux-gnu
wasm32-unknown-unknown
x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.78.0 (9b00956e5 2024-04-29)
OS version
Linux fedora 6.8.10-200.fc39.x86_64