rustup: 1.28.0 does not accept components separated by spaces
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
Hello,
At work, we use
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path -y --default-toolchain nightly-2025-02-11 -c cargo rustc rust-src
to install a specific version of rust in our CI environment but since latest version (ie: v1.28.0), it fails with:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path -y --default-toolchain nightly-2025-02-11 -c cargo rustc rust-src
info: downloading installer
error: error: unexpected argument 'rustc' found
Usage: rustup-init[EXE] [OPTIONS]
For more information, try '--help'.
After reading https://blog.rust-lang.org/2025/03/02/Rustup-1.28.0.html I understand that some amount of backward incompatible changes have been released (with very short notice) but I don’t understand:
- Why it impacts my current workflow since I am specifically asking for a toolchain
- How to fix it. I am absolutely able to fix my CI configuration, but at the moment, I have no idea how and the error message doesn’t provide any kind of help.
Thank you in advance for your help 👍
Steps
curl --proto ‘=https’ --tlsv1.2 -sSf https://sh.rustup.rs | sh -s – --no-modify-path -y --default-toolchain nightly-2025-02-11 -c cargo rustc rust-src
Possible Solution(s)
No response
Notes
No response
Rustup version
1.28.0
Installed toolchains
nightly-2025-02-11
OS version
Linux
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 17 (10 by maintainers)
Commits related to this issue
- Fix rustup `--component` Breaking change, see https://github.com/rust-lang/rustup/issues/4220. — committed to use-ink/docker-images by cmichi 2 years ago
The usage was never clearly defined.
But as the reporter of #4073, I have only ever used tooling that accepts
-c a -c b -c dand-c a,b,d. I would never expect a named argument to accept a space separated list (-c a b d).If space separated components are convenient, you can still issue a toolchain install first, and then run
rustup component add <component>..., which takes the components as positional arguments. This is what cargo-msrv does, for example.I’ve tried to emulate the different behaviors to see how they stack up with each other
rustup 1.25.0
rustup 1.26.0
rustup 1.27.1
rustup 1.28.0
Note:
toolchainlost itsrequiredstatus in the port toclap_derive. A common mistake people make is they assumeOptionis the only way to make things optional butVecdoes it as well because aVecnaturally represents storing 0 items.-c a,b d-c a -c b dd -c a b-c a b dbtw if you make
toolchainaction=Appendbutnum_args=1, then it won’t allow splitting toolchain values around flags.From my comment at https://github.com/rust-lang/rustup/issues/4073#issuecomment-2471006304
Actually accepting multiple values per flag is a problematic case, see the warning in the docs. To support cases like
-c a b d, the parser cannot be strictly greedy (is another value available? then its automatically part of-c) but needs a form of backtracking (backtrack on missing<toolchain> and give one less parameter to-c). Its possible to get that kind of backtracking behavior but it comes with its own downsides, especially in a general purpose parser (bpaf` is the only parser I’m aware that has backtracking but unsure how they handle the other trade offs).The only way to address this with clap is to regress #4073. For me, a question is whether
-c a b dandd -c a bwas intentional or an accidental slip of behavior because of how convoluted clap v2’s API was (needed arequires_delimiter(true)to opt-out of it). I remember being concerned about preserving behavior when upgrade Cargo to clap v3 and surprised to see they actually protected against it.To be clear, that would regress #4073. Maybe my bias from seeing problems with
num_argsbut I would seriously consider keeping the current behavior or at least switch tonum_args=1fromtoolchainsod -c a bclearly errors, rather than getting people upgrading getting weird behavior.I believe you would just add
num_args=1..tocomponentto get the clap v2 behavior.btw iirc
num_args = 1..,is redundant for positionals, so that might be able to be removed@epage if you have any suggestions on whether/how this is possible, would be great!
Maybe rustup could have some pre-release tests in an action that run rustup.exe in various ways to make sure the CLI interface doesn’t break.
Ah yes, this is likely an artifact of our clap upgrade that might not have been as much of a conscious change. Thanks for figuring it out, we will check how to mitigate this.