-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
cargo install --bins errors if no binaries were matched with default features #10289
Labels
Comments
I guess we can extend this a little bit by telling user why exactly no bin is installed and how they can do to discover the required features. The warning message can be improved. |
My argument here is more that this shouldn't be an error in the first place, only a warning. Since nothing actually went wrong. |
bors
added a commit
that referenced
this issue
Apr 1, 2022
Don't error if no binaries were installed ### What does this PR try to resolve? Fixes #10289, which contains a thorough description of the problem. Briefly, if we interpret `cargo install` and `cargo install --bins` as "install the binaries that are available", it should not be considered an error if no binaries ended up being installed due to required features. Instead, this should provide the user with a warning that this may not have been what they intended. ### Additional information Given that #9576 seems to have stalled, I figured I'd try to land this first [after all](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/cargo.20install.20--bins.20when.20no.20binaries.20match).
Hezuikn
pushed a commit
to Hezuikn/cargo
that referenced
this issue
Sep 22, 2022
If we interpret `cargo install` and `cargo install --bins` as "install the binaries that are available", it should not be considered an error if no binaries ended up being installed due to required features. Instead, this should provide the user with a warning that this may not have been what they intended. Fixes rust-lang#10289.
Hezuikn
pushed a commit
to Hezuikn/cargo
that referenced
this issue
Sep 22, 2022
If we interpret `cargo install` and `cargo install --bins` as "install the binaries that are available", it should not be considered an error if no binaries ended up being installed due to required features. Instead, this should provide the user with a warning that this may not have been what they intended. Fixes rust-lang#10289.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
cargo install --bins
currently fails with a helpful error message if trying to runcargo install
on a library packagecargo/src/cargo/ops/cargo_install.rs
Lines 208 to 213 in 4a166de
However, it also fails (with a less helpful error message) if trying to
cargo install
on a package that has binaries, but where none of them are matched by the given specifier/feature combinations:cargo/src/cargo/ops/cargo_install.rs
Lines 324 to 326 in 4a166de
It's unclear to me whether this should be an error in general since we already emit a warning if no binaries are matched and since cargo succeeded at what it was asked to do ("install no binaries"). But there is a specific case in which I think Cargo exiting with an error is particularly unwanted:
cargo install --bins
when all binaries require non-default features. For example:In this case, the user asked to install "all binaries with default features", and did not specify any "selected features", and so "install nothing" seems like the correct thing for Cargo to do, and an error seems unwarranted. It also presents a challenge for "default" build scripts (think Rust CI job templates and the like) that want to "install binaries if there are any", which cannot just blanket run
cargo install --bins --path .
since it will fail the job for a crate with only non-default binaries. Instead, such scripts have to both search for and resolve features to figure out whethercargo install
is "safe" to run.Steps
No response
Possible Solution(s)
My take here is that
cargo install --bins
should never fail due to selecting no binaries, even if the crate has no binaries in the first place. It should just warn. I think there may be an exception to a library-only crate to help newcomers who are confused about whatinstall
does in the first place, but otherwise--bins
says (to me) "install all selected", which is true even if none were selected.Notes
/cc #9576
Version
The text was updated successfully, but these errors were encountered: