Skip to content

Notify Users of cargo +nightly install when using cargo install +nightly #10362

Closed

Description

@DrRuhe

Problem

When running cargo install +nightly ... there is no indication that it does not actually use the nightly toolchain, until the compilation runs into errors because e.g. features need nightly.

Proposed Solution

Either:
Let the user know that cargo install +nightly ... doesn't actually use nightly and instead they should use cargo +nightly install ....

Or:
just use nightly...

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 5, 2022
  2. added
    S-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
    on May 24, 2023
  3. weihanglo commented on May 24, 2023

    @weihanglo
    Member

    Should be fairly easy to tackle for only cargo install. That being said, I personally want a solution for all cargo commands. People may also type cargo build +nightly and we should catch that. The difficult part is that rustup proxy name can be custom defined.

    If we got #11702 or clap-rs/clap#4706 landed, I think it's sufficient that we target only a subset of most common ones like +stable, +beta, +nightly.

  4. epage commented on May 24, 2023

    @epage
    Contributor

    The problem is +<channel> isn't a flag per se but a positional argument.

    cargo install and cargo add are some of the few commands that even accept a positional argument, so I can see doing this in a one-off way.

    (some others accept positional arguments but those are just meant to forward to an underlying command)

  5. weihanglo commented on Jun 1, 2023

    @weihanglo
    Member

    cargo install and cargo add are some of the few commands that even accept a positional argument, so I can see doing this in a one-off way.

    Agree with that. cargo run is a thing that we probably cannot fix at this moment.

    Here are some pointers where cargo install and cargo add collect their positional arguments

    I think Cargo can send an ad-hoc error message when detecting any crate starting with +. Something like,

    error: invalid character `+` in package name: `nightly`
         Use `cargo +nightly add` if you meant to use `nightly` toolchain.
    

    (you could find a better message than mine)

  6. 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-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
    on Jun 1, 2023
  7. danilhendrasr commented on Jun 2, 2023

    @danilhendrasr
    Contributor

    Hi, I would like to take on this issue. But, just to confirm, from what I understand in order to resolve this issue we only need to make cargo emits the above error message whenever the add and install command is run with a crate name that has + in it. Is it correct?

  8. weihanglo commented on Jun 2, 2023

    @weihanglo
    Member

    That's exactly my plan so far!

    You may want to tweak the message a bit. Mine is not as good as it looks.

  9. danilhendrasr commented on Jun 2, 2023

    @danilhendrasr
    Contributor

    Got it, I'll see what I can come up with.

    @rustbot claim

  10. danilhendrasr commented on Jun 2, 2023

    @danilhendrasr
    Contributor

    I think I need more clarification.

    If the error is emitted any time the command is given a crate name that starts with + regardless if the rest of the crate name is actually the same as one of the three toolchain channels name (stable, beta, nightly), then the following part:

      Use `cargo +<crate name> add` if you meant to use `<crate name>` toolchain.
    

    of the error should only be printed if the rest of crate name after the + sign is actually the same as one of the three toolchain channels name.
    Is that correct?

  11. weihanglo commented on Jun 2, 2023

    @weihanglo
    Member

    Toolchain name can be anything, such like cargo +stage1 build.

    My best guess is, from the array of crates name strings (krates and crates in source code), if there is a string starting with +, give the user an error.

  12. added a commit that references this issue on Jun 3, 2023
    b0fa796
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-addCommand-installE-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