Skip to content

Cargo install triggering new compilation after cargo build #9272

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

Closed
gbrlsnchs opened this issue Mar 15, 2021 · 4 comments
Closed

Cargo install triggering new compilation after cargo build #9272

gbrlsnchs opened this issue Mar 15, 2021 · 4 comments
Labels
C-bug Category: bug

Comments

@gbrlsnchs
Copy link

Problem
While learning Rust, I created a simple CLI just to learn some core concepts. To build it, I run cargo build --release, and all goes well: code compiles and a binary is generated.

However, when trying to install it using cargo install --path . --locked, just after building it, Cargo triggers a new build, totally ignoring the build process that just occurred.

Steps

  1. Clone my simple CLI
  2. Checkout commit a8cb746, which is guaranteed to retrigger compilation
  3. Go to the project's root and run cargo build --release
  4. Check whether the compilation was successful and then run cargo install --path . --locked

Possible Solution(s)
N/A

Notes
I posted this issue on the forums and was advised to open this issue here.

Output of cargo version: cargo 1.50.0 (f04e7fab7 2021-02-04)

@ehuss
Copy link
Contributor

ehuss commented Mar 16, 2021

This is caused by cargo install using a different set of features than a normal cargo build. cargo install ignores dev-dependencies, so those don't influence the feature resolution.

@gbrlsnchs
Copy link
Author

gbrlsnchs commented Mar 16, 2021

This is caused by cargo install using a different set of features than a normal cargo build. cargo install ignores dev-dependencies, so those don't influence the feature resolution.

Should it be because of dev-dependencies, wouldn't this behavior also happen for projects like hyperfine (cited in my forum post, only compiles once with those same steps).

@ehuss
Copy link
Contributor

ehuss commented Mar 16, 2021

Hyperfine doesn't appear to have any dev-dependencies that add features to any shared dependencies, so the feature set ends up being the same with or without the dev-dependencies.

@ehuss
Copy link
Contributor

ehuss commented Mar 30, 2021

I'm going to close this as working as intended, though I understand that it can be surprising or confusing. Issue #2904 is tracking adding something that would help explain why this is happening.

@ehuss ehuss closed this as completed Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants