Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

workspace.default-members causes cargo run --bin from-other-crate to fail with an unhelpful error #14544

Open
kornelski opened this issue Sep 14, 2024 · 3 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug Command-run S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

Comments

@kornelski
Copy link
Contributor

Problem

In a workspace with default-members set, cargo run --bin considers only these members as expected. However, when specifying another workspace binary without -p, the error message is unhelpful, because it doesn't hint which package needs to be selected.

Steps

cargo run --bin other where the binary is in the workspace, but not in the default workspace member.

Possible Solution(s)

The error message could search other crates in the workspace and list which have a binary with the given name.

Notes

No response

Version

cargo 1.83.0-nightly (c1fa840a8 2024-08-29)
release: 1.83.0-nightly
commit-hash: c1fa840a85eca53818895901a53fae34247448b2
commit-date: 2024-08-29
host: aarch64-apple-darwin
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.7.1 (sys:0.4.74+curl-8.9.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 15.0.0 [64-bit]
@kornelski kornelski added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Sep 14, 2024
@epage
Copy link
Contributor

epage commented Sep 14, 2024

Could you provide full reproduction steps and example failure output?

@epage epage added Command-run A-diagnostics Area: Error and warning messages generated by Cargo itself. labels Sep 14, 2024
@kornelski
Copy link
Contributor Author

cargo new crate1
cargo new crate2
  • Cargo.toml at the root
[workspace]
members = ["crate1", "crate2"]
default-members = ["crate1"]

and

cargo r --bin crate2

gives

error: no bin target named `crate2`

	Did you mean `crate1`?

Alternatively, without default-members, cargo r --bin gives:

error: "--bin" takes one argument.
Available binaries:
    crate1
    crate2

with default-members it considers just the members, which is technically correct:

error: "--bin" takes one argument.
Available binaries:
    crate1

but it could be more helpful if it also looked at other workspace members and suggested -p to select them with their binaries.

@epage epage added S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. and removed S-triage Status: This issue is waiting on initial triage. labels Sep 20, 2024
@epage
Copy link
Contributor

epage commented Sep 20, 2024

From a users perspective, it seems reasonable to improve. My only question is how much it would take to get the right information into the right place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug Command-run S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.
Projects
None yet
Development

No branches or pull requests

2 participants