Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with rustup toolchain uninstall <toolchain>/ with trailing slash #2873

Closed
tgnottingham opened this issue Oct 21, 2021 · 1 comment · Fixed by #2897
Closed

Issues with rustup toolchain uninstall <toolchain>/ with trailing slash #2873

tgnottingham opened this issue Oct 21, 2021 · 1 comment · Fixed by #2897

Comments

@tgnottingham
Copy link

Given the existence of a custom toolchain, toolchain-a, rustup toolchain uninstall toolchain-a/ (note trailing /) will not delete the symbolic link at ~/.rustup/toolchains/toolchain-a, which is expected, but will produce an error and delete the contents of the directory linked to toolchain-a, which is unexpected.

$ ls ~/rust/toolchains/foo
bin  lib
$ rustup toolchain link toolchain-a ~/rust/toolchains/foo
$ rustup toolchain uninstall toolchain-a/
info: uninstalling toolchain 'toolchain-a/'
error: could not remove 'install' directory: '/home/tgnottingham/.rustup/toolchains/toolchain-a/': Not a directory (os error 20)
$ ls ~/rust/toolchains/foo
$

I might expect it to say something like this instead:

$ rustup toolchain uninstall toolchain-a/
info: no toolchain installed for 'toolchain-a/'
        Did you mean 'toolchain-a'?

For non-custom toolchains, the problem is different. As far as I can tell, it doesn't delete anything, but it does produce an error:

$ rustup toolchain uninstall nightly-2021-10-10-x86_64-unknown-linux-gnu/
info: uninstalling toolchain 'nightly-2021-10-10-x86_64-unknown-linux-gnu/'
error: could not remove 'update hash' file: '/home/tgnottingham/.rustup/update-hashes/nightly-2021-10-10-x86_64-unknown-linux-gnu/': could not remove 'update hash' file: '/home/tgnottingham/.rustup/update-hashes/nightly-2021-10-10-x86_64-unknown-linux-gnu/': Not a directory (os error 20)

However, using an abbreviated name of the toolchain plus a /, e.g. nightly-2021-10-10/, fails more or less the way I'd expect:

$ rustup toolchain uninstall nightly-2021-10-10/
info: no toolchain installed for 'nightly-2021-10-10/'

(Though, here also, a Did you mean 'nightly-2021-10-10'?, would be a nice bonus feature.)


Output of rustup --version:

rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.55.0 (c8dfcfe04 2021-09-06)`

Output of rustup show:

Default host: x86_64-unknown-linux-gnu
rustup home:  /home/tgnottingham/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
beta-x86_64-unknown-linux-gnu
nightly-2021-10-10-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu
toolchain-a

installed targets for active toolchain
--------------------------------------

wasm32-unknown-unknown
x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.55.0 (c8dfcfe04 2021-09-06)
@kinnison
Copy link
Contributor

kinnison commented Nov 8, 2021

It seems to me that simply removing trailing slashes is one reasonable approach to this. i.e. normalising toolchain names in that way. It's an unusual situation for people but an easy enough fix. If someone wants to propose a PR for this, I'd be grateful.

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

Successfully merging a pull request may close this issue.

2 participants