Skip to content

Cargo run silently passes arguments to target binary if user accidentally messes up +version order #10535

Open
@orlp

Description

@orlp

Problem

I recently was (for a short while) tricked into believing my program was stuck in an infinite loop. I had ran the command

cargo run +nightly --release

It took me a while to realize that what I had written resulted in target/debug/foo.exe +nightly --release being ran, instead of running in release mode with the nightly compiler. I feel this is quite error prone, and that it's undesirable this happens entirely silently.

Proposed Solution

I propose that we display a warning when the first argument that cargo run interprets as an argument for the binary to run starts with a +. The warning can be silenced by prefixing the start of your binary argument list with -- (which you probably already should be doing anyway). So cargo run -- +nightly --release would not result in a warning, as it indicates the user really intended this behavior.

It could also simply be an error rather than a warning to start the first argument with a +, which would've probably been the better behavior from the start, but this could break existing scripts.

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    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-runS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions