-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 picks an older version of a dep that breaks the build #7866
Comments
I think it is working as expected. pnet_macros 0.25 declares a dependency on I don't know why |
@ehuss Thanks for the quick response. What you explained makes sense. I am able to simplify the reproduction further to just one new crate that:
I will update the issue I filed on libpnet. Now I feel that we could use a bit more visibility from Cargo. Would Or maybe another command line option to "explain" how the dep versions are calculated? Also do you think it would have avoided this issue if pnet_packet was requiring a more recent version of pnet_macros? Or would that have caused conflicting dep specs thus stopped cargo from finding a version? [Minor grammar fixes] |
UPDATE: If I add a dep on pnet_macros in a crate, like below:
|
I'm going to close this since it is expected behavior. However, I have opened #7929 for the feature request to make it easier to discover and explain why it happens. |
@ehuss Thanks for creating the feature request issue. |
Problem
This is tricky issue. Cargo insists on using an older and incompatible version of a dep crate that breaks the build, only in certain combination(s) of the deps.
This the compilation error comes from the simplified reproduction when it fails:
This dep crate name is pnet_macros. In v0.21.0 of this crate, this function
minimum_packet_size()
was indeed not const. It's declared const since v0.22.0. There are newer versions of this crate in crates.io. Cargo picks v0.21.0 in the reproduction setup, and a newer version in a non-reproduction setup.This crate is part of libpnet which consists of a few more crates. One of them depends on pnet_macros with this spec:
My crate does not use pnet_macros directly. It uses pnet_packet. I was using libpnet v0.23.0. It was yanked. So I upgraded to libpnet v0.25.0. Build fails with both.
My crate shares a workspace with another crate. The issue didn't happen until I added a benchmark test, and dev-dep on criterion, in the second crate. The second crate does not use libpnet. The two crates are not related (In the future one crate will use another but that is irrelevant here).
It looks like that adding dev-dep on criterion somehow causes Cargo to pick an older version of another dep that breaks the build.
Cargo should be consistent in picking the dep versions.
Steps
cargo build --bin one
.cargo build --bin one
and expect the build to finish without issue.Possible Solution(s)
Notes
Output of
cargo version
:cargo 1.41.0 (626f0f4 2019-12-03)
cargo clean
run and Cargo.lock deleted.The text was updated successfully, but these errors were encountered: