-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
A manifest command is suggested for invalid input #13332
Comments
Note that the alternative would have been that no such subcommand exists. $ cargo run-gfdklfgjdfjkgjkldg
error: no such command: `run-gfdklfgjdfjkgjkldg`
View all installed commands with `cargo --list`
Find a package to install `run-gfdklfgjdfjkgjkldg` with `cargo search cargo-run-gfdklfgjdfjkgjkldg` The reason we gave the manifest command error, instead of no-such-subcommand error, is because of the slashes in the argument. We interpreted that as a path (seeing as those are illegal for subcommand names). For myself, I'm having a hard time seeing how this kind of situation would be common enough for us to detect and report for. This requires a lack of spaces between the subcommand name and wherever a path-like may show up. Cases besides |
People might have an alias $ cargo test-runner./snapshots
error: running `test-runner./snapshots` requires `-Zscript` The message is not ideal for new Rust users to identify what's going on, as it points to a nightly feature they don't know. Maybe we could give the “no such subcommand” error still, with a bit richer message for -Zscript, so people don't know it can learn about its existence :) $ cargo test-runner./snapshots
warning: no such subcommand: `test-runner./snapshots`
error the `cargo <single-file-package>` command is unstable, and only available on the nightly channel of Cargo, but this is the `beta` channel
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
See https://github.com/rust-lang/cargo/issues/12207 for more information about the `cargo <single-file-package>` command. patchfile
Or maybe other ad-hoc message can help |
I'm fine with providing some way to combine the messages pre-stabilization. My comment was more looking forward to when we do stabilize. How should the error look in that case? I feel like we should start there and work backwards or else we'll just mask this until stabilization and then regress. |
@epage What if we check to make sure the path actually exists first? Then we could say something like we interpreted the command as an attempt to run a script, but the file doesn't exist. |
It's hard to guess the intent of a user, and “no such subcommand” is a good choice in the meantime when waiting for feedback from others. Some ideas:
|
Problem
My friend is learning Rust and was given a typo in an example command. She was told to type:
Even though what she wanted was:
The error she got told her to use
-Zscript
, a nightly flag which runs singular Rust files as scripts. I don't know how Cargo came to the conclusion that this was a manifest command, or how it interpreted the space-separated string as one command name, but that's what it did.Steps
cargo -q run - https://rust-lang.org
Possible Solution(s)
This should probably just give an error, saying that it's not a valid command. Maybe a help message suggesting spaces.
Notes
No response
Version
The text was updated successfully, but these errors were encountered: