Skip to content

cargo install --release gives a confusing error #12009

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
jyn514 opened this issue Apr 20, 2023 · 3 comments
Closed

cargo install --release gives a confusing error #12009

jyn514 opened this issue Apr 20, 2023 · 3 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@jyn514
Copy link
Member

jyn514 commented Apr 20, 2023

Problem

I have a friend who doesn't know rust and tried to install a program written in Rust. First he tried cargo build and that ran too slowly, so I told him to use --release. Then he tested it to his satisfaction and tried to install it:

$ cargo install --release --path . --locked
error: unexpected argument '--release' found

  note: argument '--examples' exists

Usage: cargo install --examples [crate]...

For more information, try '--help'.

The problem here is that the defaults are flipped between build and install: build defaults to the dev profile and has a --release flag, install defaults to the release profile and has a --debug flag. That seems ok, but the error message is unhelpful.

Proposed Solution

Improve the error message:

$ cargo install --release --path . --locked
error: unexpected argument '--release' found

  note: `install` uses the release profile by default
  help: remove `--release` to install using the release profile: `cargo install --path . --locked`

Usage: cargo install [OPTIONS] [crate]...

For more information, try '--help'.

Notes

Don't remember when this happened originally, but the error messages in the issue description came from cargo 1.68.2 (6feb7c9cf 2023-03-26).

@jyn514 jyn514 added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Apr 20, 2023
@jyn514
Copy link
Member Author

jyn514 commented Apr 20, 2023

It probably makes sense to do the same for cargo build --debug, which gives a similarly unhelpful error currently:

$ cargo build --debug
error: unexpected argument '--debug' found

Usage: cargo build [OPTIONS]

For more information, try '--help'.

@epage
Copy link
Contributor

epage commented Apr 20, 2023

clap-rs/clap#4706 would be useful for this

@weihanglo
Copy link
Member

#11702 wants exactly the same feature. Close this as it seems to be a duplicate. I'll add this case to the list there.

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

3 participants