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

"rustup add target ..." could warn user that they meant "rustup target add ..." #4024

Open
gmatht opened this issue Sep 18, 2024 · 2 comments

Comments

@gmatht
Copy link

gmatht commented Sep 18, 2024

Problem you are trying to solve

The following error message isn't as helpful as it could be:

$ rustup add target x86_64-unknown-linux-gnux32
error: unrecognized subcommand 'x86_64-unknown-linux-gnux32'

Usage: rustup target <COMMAND>

For more information, try '--help'.

Solution you'd like

I think it would be more useful if we added: Did you mean "rustup target add x86_64-unknown-linux-gnux32"?.

Notes

"add target" is the more natural language way of writing the command, so I feel we should help users who make this mistake.

@djc
Copy link
Contributor

djc commented Sep 18, 2024

It is a bit of a strange error. Experimenting:

djc-2021 ~ $ rustup add -h
error: invalid value 'add' for '[+toolchain]': error: "add" is not a valid subcommand, so it was interpreted as a toolchain name, but it is also invalid. To override the toolchain using the 'rustup +toolchain' syntax, make sure to prefix the toolchain override with a '+'

For more information, try '--help'.
djc-2021 ~ $ rustup add target x86_64-unknown-linux-gnux32
error: unrecognized subcommand 'x86_64-unknown-linux-gnux32'

Usage: rustup target <COMMAND>

For more information, try '--help'.
djc-2021 ~ $ rustup add target
Modify a toolchain's supported targets

Usage: rustup target <COMMAND>

Commands:
  list    List installed and available targets
  add     Add a target to a Rust toolchain
  remove  Remove a target from a Rust toolchain
  help    Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

Maybe our attempts to extract a toolchain throw it off? Or maybe clap could/should be improved here?

@rami3l
Copy link
Member

rami3l commented Sep 18, 2024

It is a bit of a strange error. Experimenting:

djc-2021 ~ $ rustup add -h
error: invalid value 'add' for '[+toolchain]': error: "add" is not a valid subcommand, so it was interpreted as a toolchain name, but it is also invalid. To override the toolchain using the 'rustup +toolchain' syntax, make sure to prefix the toolchain override with a '+'

For more information, try '--help'.
djc-2021 ~ $ rustup add target x86_64-unknown-linux-gnux32
error: unrecognized subcommand 'x86_64-unknown-linux-gnux32'

Usage: rustup target <COMMAND>

For more information, try '--help'.
djc-2021 ~ $ rustup add target
Modify a toolchain's supported targets

Usage: rustup target <COMMAND>

Commands:
  list    List installed and available targets
  add     Add a target to a Rust toolchain
  remove  Remove a target from a Rust toolchain
  help    Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

Maybe our attempts to extract a toolchain throw it off? Or maybe clap could/should be improved here?

@djc This is the +toolchain shorthand breaking clap, as usual. Similar to #3156.

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

No branches or pull requests

3 participants