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

cargo install does not report needed features #11617

Closed
epage opened this issue Jan 23, 2023 · 0 comments · Fixed by #11647
Closed

cargo install does not report needed features #11617

epage opened this issue Jan 23, 2023 · 0 comments · Fixed by #11647
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-install

Comments

@epage
Copy link
Contributor

epage commented Jan 23, 2023

Problem

Commands like cargo check will report needed features, like the following in clap:

$ cargo run --example git-derive
error: target `git-derive` in package `clap` requires the features: `derive`
Consider enabling them by passing, e.g., `--features="derive"`

If you install a specific bin, you get an error telling you how to install it

$ cargo install pulldown-cmark --no-default-features --bin pulldown-cmark
    Updating crates.io index
  Installing pulldown-cmark v0.9.2
error: failed to compile `pulldown-cmark v0.9.2`, intermediate artifacts can be found at `/tmp/cargo-installgpjZMz`

Caused by:
  target `pulldown-cmark` in package `pulldown-cmark` requires the features: `getopts`
  Consider enabling them by passing, e.g., `--features="getopts"`

However, if you do a general install (the more likely case), you get notified nothing is installed but no hint as to what features would change this

$ cargo install pulldown-cmark --no-default-features
    Updating crates.io index
  Installing pulldown-cmark v0.9.2
   Compiling version_check v0.9.4
   Compiling memchr v2.5.0
   Compiling pulldown-cmark v0.9.2
   Compiling bitflags v1.3.2
   Compiling unicase v2.6.0
    Finished release [optimized] target(s) in 1.86s
warning: none of the package's binaries are available for install using the selected features

Proposed Solution

Report to the user features to enable to install binaries

Notes

No response

@epage epage added Command-install C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` labels Jan 23, 2023
bors added a commit that referenced this issue Jan 31, 2023
Make cargo install report needed features

### What does this PR try to resolve?

The problem described in issue #11617 where cargo tells the user, that no binaries are available
because of the chosen features, but does not tell which features could be enabled to fix the
situation.

Fixes #11617.

### How should we test and review this PR?

Try to cargo install a crate, where all binaries need some features enabled, without enabling
the features and check the error message.

The test suite already contains tests for this.
@bors bors closed this as completed in 01fd6be Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-install
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant