Skip to content

Cargo should give helpful errors when unsupported flags are used. #11702

Closed

Description

@jonhoo

Problem

There are several flags one might imagine users passing to Cargo that aren't supported yet. It'd be nice if we told users who try to use these what to use instead, and perhaps also linked to the issue (if any) proposing to add such a flag. Some examples:

Proposed Solution

No response

Notes

No response

Activity

  1. added
    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
    on Feb 11, 2023
  2. added
    A-cliArea: Command-line interface, option parsing, etc.
    on Feb 11, 2023
  3. weihanglo commented on Feb 13, 2023

    @weihanglo
    Member

    Does it make sense having this as a built-in mechanism in clap for suggesting an alternative flag?

  4. epage commented on Feb 13, 2023

    @epage
    Contributor

    @weihanglo I think that can make sense to seed clap with specific suggestions and not just rely on the automatic suggestions and that would help simplify things for application, like cargo. Mind opening an issue?

  5. weihanglo commented on Apr 21, 2023

    @weihanglo
    Member

    More examples:

    • There's no --debug for cargo build. Only --release.
    • There's no --release for cargo install. Only --debug.

    These does confuse people a lot. See #12009.

  6. weihanglo commented on Apr 21, 2023

    @weihanglo
    Member

    I am not sure if we should wait for upstream fix or make our own custom suggestion. Let's label it as waiting for upstream first. We still seek ad-hoc solutions if somebody is interested in.

    @rustbot label +S-blocked-external

  7. added
    S-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
    on Apr 21, 2023
  8. weihanglo commented on Aug 17, 2023

    @weihanglo
    Member

    clap-rs/clap#5075 just got landed with clap@4.3.22. People, we now can have basic suggestions for unsupported arguments!

    I'll write down a list of flags of interest and instructions shortly.

    @rustbot label -S-blocked-external +S-accepted +E-easy

  9. added
    E-easyExperience: Easy
    S-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review
    and removed
    S-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
    on Aug 17, 2023
  10. weihanglo commented on Aug 22, 2023

    @weihanglo
    Member

    Not sure if this is the relevant clap issue clap-rs/clap#4853. Supposed we are going to leverage UnknownArgumentValueParser for those well-known unknown arguments, it might cause unwanted typo suggestion for them.

    Let me label it blocked on that issue at this moment.

    @rustbot label -S-accepted +S-blocked-external

  11. added
    S-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
    and removed
    S-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review
    on Aug 22, 2023
  12. epage commented on Aug 22, 2023

    @epage
    Contributor

    @weihanglo could you give an example of where that causes a problem worth blocking this issue?

  13. weihanglo commented on Aug 22, 2023

    @weihanglo
    Member

    Something like this? Though for short aliases clap doesn't suggest them I feel like. If that's the case we can continue working on short aliases part.

        Finished dev [unoptimized + debuginfo] target(s) in 0.16s
         Running `target/debug/cargo install --please`
    error: unexpected argument '--please' found
    
      tip: a similar argument exists: '--release'
    
    Usage: cargo install --release [crate]...
    
    For more information, try '--help'.
  14. epage commented on Aug 23, 2023

    @epage
    Contributor

    Asking to better characterize the problem: is that always bad though?

    Take the prior work in #12529, like cargo test --keep-going. If the user thought it should work and did cargo test --keep-goign, today they would get a correction and then be pointed to the correct flag (yes, ideally the two steps would be one step which might be a consideration where suggest_arg is appropriate). With the proposed change, the user would just get an unexpected argument error and would fall back to --help. Trying to understand which path is best.

  15. weihanglo commented on Aug 23, 2023

    @weihanglo
    Member

    It's not inherently bad, and agree with that two steps is better than infinite steps searching in --help. Just it is lying that “a similar argument exists”, which doesn't.

    I am convinced that it's not really a blocker 😆. Would be great if clap can improve the situation.

    @rustbot label +S-accepted -S-blocked-external

  16. added
    S-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review
    and removed
    S-blocked-externalStatus: ❌ blocked on something out of the direct control of the Cargo project, e.g., upstream fix
    on Aug 23, 2023
  17. 0xPoe commented on Sep 19, 2023

    @0xPoe
    Member

    @rustbot claim

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

Metadata

Metadata

Assignees

Labels

A-cliArea: Command-line interface, option parsing, etc.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`E-easyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions