rustup
rustup copied to clipboard
Allow wildcards (`*`) when matching toolchains
Problem you are trying to solve
I update nightly frequently and always wind up with a lot of toolchains that I am unlikely to use again:
$ rustup show
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu
nightly-2023-04-29-x86_64-unknown-linux-gnu
nightly-2023-06-15-x86_64-unknown-linux-gnu
nightly-2023-06-19-x86_64-unknown-linux-gnu
nightly-2023-07-14-x86_64-unknown-linux-gnu
nightly-2023-07-22-x86_64-unknown-linux-gnu
nightly-2023-07-28-x86_64-unknown-linux-gnu
nightly-2023-08-08-x86_64-unknown-linux-gnu
nightly-2023-08-24-x86_64-unknown-linux-gnu
1.60-x86_64-unknown-linux-gnu
1.63-x86_64-unknown-linux-gnu
stage1
stage2
1.68.2-x86_64-unknown-linux-gnu
1.71.0-x86_64-unknown-linux-gnu
1.71.1-x86_64-unknown-linux-gnu
active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.75.0-nightly (e5cfc5547 2023-10-28)
There is no easy way to remove all toolchains matching a pattern
Solution you'd like
Allow *
as a wildcard for removal and other relevant commands so that this works:
$ rustup toolchain remove nightly-2023-*
info: no toolchain installed for 'nightly-2023-*'
Notes
rustup 1.26.0 (5af9b9484 2023-04-05)
@tgross35 Thanks a lot for filing this issue!
This is also one of the pain points that I often encounter when using rustup
and elan
, so I'm quite willing to address it. However, due to how rustup
resolves toolchain names [^1], this might not be a simple fix.
[^1]: In case you don't know, you can do something like rustup toolchain uninstall 1.39-x86_64
.
Furthermore, one might argue that a one-line script like the following will suffice:
rustup toolchain list | cut -d ' ' -f1 | grep nightly-2023- | xargs rustup uninstall
@rbtcollins @djc What do you think?
the (default) in rustup toolchain list
makes that harder to work with.
I wonder if dropping that default, making the list more API-like, adding 'rustup toolchain default' or something similar, would make this nicer.
I'm a bit skeptical of rustup doing its own globbing here.
@rbtcollins Okay, I think it would be better to find a workaround then.
IMHO it would be nice if we can leave the output as-is and add a new flag specifically to give simple outputs for non-interactive uses.
For instance, this is what we'll get if we borrow the "single-column mode" (written as -1
) from brew
:
> rustup toolchain list
stable-aarch64-apple-darwin (default)
nightly-aarch64-apple-darwin
> rustup toolchain list -1
stable-aarch64-apple-darwin
nightly-aarch64-apple-darwin
I don't quite like -1
though, and would possibly call it --simple
/-s
.
Or we can add a new --quiet
for this purpose.
Anyway, this change should probably be mirrored to rustup target list
and other similar commands.
I like -q/--quiet
for this!
I'll find some time to implement this --quiet
thing then. Claim.
Now that the output format is being changed in https://github.com/rust-lang/rustup/pull/3225, I think we should wait a bit before implementing this.