You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cargo fails to select a version for dependency because another package in the workspace causes a version conflicts.
Current Behavior
error: failed to select a version for `zeroize`.
... required by package `num-bigint-dig v0.8.2`
... which satisfies dependency `num-bigint = "^0.8.2"` of package `rsa v0.8.0`
... which satisfies dependency `rsa = "^0.8.0"` of package `sqlx-mysql v0.7.0-alpha.2`
... which satisfies dependency `sqlx-mysql = "=0.7.0-alpha.2"` of package `sqlx v0.7.0-alpha.2`
... which satisfies dependency `sqlx = "^0.7.0-alpha.2"` of package `crate-2 v0.1.0 (/home/hamza/code/tmp/cargo-issue/crates/crate-2)`
versions that meet the requirements `^1.5` are: 1.6.0, 1.5.7, 1.5.6, 1.5.5, 1.5.4, 1.5.3
all possible versions conflict with previously selected packages.
previously selected package `zeroize v1.3.0`
... which satisfies dependency `zeroize = "=1.3"` of package `x25519-dalek v1.2.0`
... which satisfies dependency `x25519-dalek = "^1.2.0"` of package `vodozemac v0.3.0`
... which satisfies dependency `vodozemac = "^0.3.0"` of package `crate-1 v0.1.0 (/home/hamza/code/tmp/cargo-issue/crates/crate-1)`
failed to select a version for `zeroize` which could resolve this conflict
Expected behavior
Build works fine
Steps
Set up a project as detailed below
Run cargo check
Notice the failure
Details
$ exa -T
.
├── Cargo.toml
└── crates
├── crate-1
│ ├── Cargo.toml
│ └── src
│ └── main.rs
└── crate-2
├── Cargo.toml
└── src
└── main.rs
$ cat Cargo.toml
[workspace]
members = ["crates/*"]
resolver = "2"
$ cat crates/crate-1/Cargo.toml
[package]
name = "crate-1"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
vodozemac = { version = "0.3.0", default-features = true, features = ["js"] }
$ cat crates/crate-2/Cargo.toml
[package]
name = "crate-2"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sqlx = { version = "0.7.0-alpha.2", features = [ "runtime-tokio", "postgres", "uuid", "chrono" ] }
Possible Solution(s)
Duplicate the dependency across packages. It is possible to build this workspace such that crate-1 depends on zeroize 1.3 and crate-2 depends on zeroize 1.6
Highly recommend reading the second one. It's a summary from a Cargo team member.
I would also suggest posting an issue to the package that pins their dependency to an exact version. In the long-term pinning could bring more harm than benefit, making dependency stagnate and couldn't receive security patches.
Going to close this as it is unlikely to move forward without a strong RFC. Thanks!
Problem
Cargo fails to select a version for dependency because another package in the workspace causes a version conflicts.
Current Behavior
Expected behavior
Build works fine
Steps
Details
Possible Solution(s)
Duplicate the dependency across packages. It is possible to build this workspace such that
crate-1
depends on zeroize 1.3 andcrate-2
depends on zeroize 1.6Notes
No response
Version
The text was updated successfully, but these errors were encountered: