-
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 is unable to resolve dependency versions #6584
Comments
One other note is that it had no issues resolving this with two different versions when the version numbers were the same. Prior to the release of 1.4, we had diesel 1.3.3 (from crates.io) and the local version of diesel (also versioned 1.3.3 but with different code) both in the same build. The crates.io version was used as a dependency for diesel_infer_schema, while the local version was used for everything else. |
The version requirements |
Both requirements are intended as written there. @sgrif It worked before because cargo was able to select a version (1.3.3) for both. That |
Ok! In that case I think this is not a cargo issue, right? |
Let's elaborate this in another way: I do not understand the reasoning behind that version resolution schema. Yes cargo should try to select one common major version, but if that's not possible (because one crate uses a explicit version as internal dependency for example) it should be possible for cargo to just select 2 version. Additionally that already works fine if the dependencies have different major versions. |
@alexcrichton Cargo should allow two different versions of this library to be used, shouldn't it? My understanding was that incompatible version constraints didn't matter here, it'd just use 1.3 for the library that required it, and 1.4 where that was requested. It was previously using two versions before this, they just happened to have the same version number. Looking in the |
Actually looking at |
Ah that's just how Cargo has always worked. Cargo allows multiple major versions of a crate, but all selected versions of a crate must be semver-incompatible (e.g. can't have 1.3.0 and 1.4.0 as they're semver compatible). There's a whole bunch of reasoning behind why Cargo does this, but it's probably a bit much to get in here. We'd like to change this, we just haven't yet.
One example is that if you're using 1.3.0 and I'm using 1.4.0 and someone tries to use us both, they get compile errors that look obscure as opposed to a version resolution error. Instead we need to be using the same version to be used together.
Yes, but only if they're semver incompatible (and 1.3.0 and 1.4.0 are compatible, 1.4.0 wasn't a breaking change relative to 1.3.0 semver-wise)
That's because Cargo's interpretation of semver means that 0.5.x and 0.6.y are semver-incompatible. The 0.6 branch was a breaking change relative to the 0.5 branch. The |
The same already happens if you try to use 2 semver incompatible versions, so that would be nothing new. (And that only affects dependencies exposed in public interfaces). So that seems to be a weak argument for me.
That's the actual point here: We "know" what we are doing. That one version is a internal (build-)dependency. That other one a "public" (runtime) dependency. So they cannot collide… |
Yeah, the semver incompatible restriction seems really pointless to me since you get those exact same errors regardless of semver compatibility. Would this need an RFC to be changed? |
This isn't really the place to debate the merits of Cargo's current implementation. Since Cargo is working as intended I'm going to close this issue, but a follow-up can be opened which is targeted about possibly changing Cargo's behavior. For changing this, yes it would require an RFC |
Thanks for taking the time to clarify this for us |
@alexcrichton I actually think there still is a bug here, since Cargo will allow multiple versions of a dependency if they have identical version numbers (when one is depended on as |
Cargo considers those two different crates because they come from two different sources. One is from crates.io and one is from a "path source". Conflicting versions are allowed from different sources because the different sources produce different crates that can't ever be unified. |
…argo#6584 (comment) > The `~` requirement is indeed more strict than `^`, but Cargo strongly discourages usage of any version requirement other than `^` unless you're really sure you know what you're doing
## Proposed Changes I did some gardening 🌳 in our dependency tree: - Remove duplicate versions of `warp` (git vs patch) - Remove duplicate versions of lots of small deps: `cpufeatures`, `ethabi`, `ethereum-types`, `bitvec`, `nix`, `libsecp256k1`. - Update MDBX (should resolve #3028). I tested and Lighthouse compiles on Windows 11 now. - Restore `psutil` back to upstream - Make some progress updating everything to rand 0.8. There are a few crates stuck on 0.7. Hopefully this puts us on a better footing for future `cargo audit` issues, and improves compile times slightly. ## Additional Info Some crates are held back by issues with `zeroize`. libp2p-noise depends on [`chacha20poly1305`](https://crates.io/crates/chacha20poly1305) which depends on zeroize < v1.5, and we can only have one version of zeroize because it's post 1.0 (see rust-lang/cargo#6584). The latest version of `zeroize` is v1.5.4, which is used by the new versions of many other crates (e.g. `num-bigint-dig`). Once a new version of chacha20poly1305 is released we can update libp2p-noise and upgrade everything to the latest `zeroize` version. I've also opened a PR to `blst` related to zeroize: supranational/blst#111
## Proposed Changes I did some gardening 🌳 in our dependency tree: - Remove duplicate versions of `warp` (git vs patch) - Remove duplicate versions of lots of small deps: `cpufeatures`, `ethabi`, `ethereum-types`, `bitvec`, `nix`, `libsecp256k1`. - Update MDBX (should resolve #3028). I tested and Lighthouse compiles on Windows 11 now. - Restore `psutil` back to upstream - Make some progress updating everything to rand 0.8. There are a few crates stuck on 0.7. Hopefully this puts us on a better footing for future `cargo audit` issues, and improves compile times slightly. ## Additional Info Some crates are held back by issues with `zeroize`. libp2p-noise depends on [`chacha20poly1305`](https://crates.io/crates/chacha20poly1305) which depends on zeroize < v1.5, and we can only have one version of zeroize because it's post 1.0 (see rust-lang/cargo#6584). The latest version of `zeroize` is v1.5.4, which is used by the new versions of many other crates (e.g. `num-bigint-dig`). Once a new version of chacha20poly1305 is released we can update libp2p-noise and upgrade everything to the latest `zeroize` version. I've also opened a PR to `blst` related to zeroize: supranational/blst#111
## Proposed Changes I did some gardening 🌳 in our dependency tree: - Remove duplicate versions of `warp` (git vs patch) - Remove duplicate versions of lots of small deps: `cpufeatures`, `ethabi`, `ethereum-types`, `bitvec`, `nix`, `libsecp256k1`. - Update MDBX (should resolve sigp#3028). I tested and Lighthouse compiles on Windows 11 now. - Restore `psutil` back to upstream - Make some progress updating everything to rand 0.8. There are a few crates stuck on 0.7. Hopefully this puts us on a better footing for future `cargo audit` issues, and improves compile times slightly. ## Additional Info Some crates are held back by issues with `zeroize`. libp2p-noise depends on [`chacha20poly1305`](https://crates.io/crates/chacha20poly1305) which depends on zeroize < v1.5, and we can only have one version of zeroize because it's post 1.0 (see rust-lang/cargo#6584). The latest version of `zeroize` is v1.5.4, which is used by the new versions of many other crates (e.g. `num-bigint-dig`). Once a new version of chacha20poly1305 is released we can update libp2p-noise and upgrade everything to the latest `zeroize` version. I've also opened a PR to `blst` related to zeroize: supranational/blst#111
@alexcrichton Could you provide some more color about the reasons why Cargo doesn't support multiple semver-compatible versions of the same package? I've been running into this more when crate authors disagree about semver-compatibility over MSRV bumps that causes a lot of painful upstream changes; personally, I've needed to fork a lot of packages just to tweak Cargo.toml bounds which is difficult to maintain. If there's support for this change, I would like to help draft an RFC so any guidance around that would also be helpful. |
I don't think a closed issue from three years ago is likely to be a good home for this discussion. I do not have inside information, I was not around when this compromise was made. But as a current member of the cargo team, one of the places I've recently written up my understanding is: If the cause of the arguments over versioning is MSRV tensions, then it is likely to be more productive to suggest changes that directly affect MSRV aware resolution. Any RFC that allows multiple semver compatible versions will need to describe precisely when it will be allowed, when it will not be allowed, how the resolver will decide if it is allowed, how that decision will be made clear to the user who cares, and how a user would be able to control if it applies on a case-by-case basis. Resolution is already NP-complete so none of those questions are straightforward. |
0.4.6 contains some deprecations and performance regressions which I want to deal with later.
winnow 0.4.2 bumped MSRV to 1.64. We want to bump our MSRV only after Tauri does.
Problem
Cargo is unable to select two versions of diesel as dependency of some crate.
I've seen this working if the other version of diesel is 0.x, so this does not make any sense for me that a it is not possible to use two semver compatible versions at the same time as dependency if explicitly requested.
Detailed dependency situation:
We have a workspace containing several crates. Most of them depend on
diesel = "1.4.0"
. Additionally there is one crate (diesel_tests), that depends ondiesel_infer_schema = "1.3.0"
. Internallydiesel_infer_schema
depends ondiesel = "~1.3.0"
which causes the version selection problem shown above.Steps
/path/to/diesel_clone/diesel/
Possible Solution(s)
Cargo should be able to use 2 versions of the same dependency if requested explicitly even if there would be an semver compatible version if the versions are specified in a other way.
(I.e. That should just work)
Notes
Output of
cargo version
:cargo 1.31.0 (339d9f9c8 2018-11-16)
1.31.0
(installed through rustup)ubuntu 18.10
cc @sgrif @killercup @Eijebong (That breaks our CI)
The text was updated successfully, but these errors were encountered: