Skip to content

Improve error message for no such subcommand #10900

@CAD97

Description

@CAD97

Problem

With the rustup changes to set $RUSTC et al, it's become more likely that people will accidentally use +toolchain on cargo/rustc/etc directly rather than through the rustup shims. While we shouldn't try to handle the toolchain flag ourselves, it would be beneficial to recognize it in the "no such subcommand" path and print a help note notifying the user that cargo received the +toolchain argument but can't handle it.

〉main:pegcel〉rustup which cargo
D:\.rust\rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\cargo.exe
〉main:pegcel〉D:\.rust\rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\cargo.exe +nightly check
error: no such subcommand: `+nightly`

Proposed Solution

〉main:pegcel〉rustup which cargo
D:\.rust\rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\cargo.exe
〉main:pegcel〉D:\.rust\rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\cargo.exe +nightly check
error: no such subcommand: `+nightly`

        Did you mean to run cargo through rustup?
        Cargo does not handle `+toolchain` directives itself.

Notes

Some rustup context:

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Error and warning messages generated by Cargo itself.A-rustupArea: rustup interactionC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`E-easyExperience: Easy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions