Cargo resolver picks two versions of a crate, even when one is enough · Issue #10599 · rust-lang/cargo (original) (raw)

Problem

Diesel 2 (rc.0) depends on uuid >=0.7.0, <2.0.0 and my app depends on uuid =0.8.2 because some other deps depend on that.

Cargo resolver always pick two versions of uuid, 0.8.2 and 1.0.0. (in my case)

It's the same if I remove the =, also the same if I remove uuid dep from my app and only some other deps depend on uuid 0.8.2.

Test scenario to cover this case:

#[cargo_test]
fn uuid_test() {
    Package::new("uuid", "0.8.2").publish();
    Package::new("uuid", "1.0.0").publish();
    Package::new("diesel", "2.0.0")
        .dep("uuid", ">=0.7.0, <2.0.0")
        .publish();

    let p = project()
        .file(
            "Cargo.toml",
            r#"
            [package]
            name = "foo"
            version = "1.0.0"

            [dependencies]
            diesel = "2.0"
            uuid = "0.8.2"
            "#,
        )
        .file("src/lib.rs", "")
        .build();

    p.cargo("tree -i uuid").with_stdout_contains("uuid v0.8.2").run();
}

Steps

  1. Create a new project
  2. Add the following deps:
diesel = {version = "2.0.0-rc.0", features = ["uuid"]}
uuid = "=0.8.2"
  1. Run cargo tree -i uuid

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.60.0 (d1fd9fe 2022-03-01)
release: 1.60.0
commit-hash: d1fd9fe2c40a1a56af9132b5c92ab963ac7ae422
commit-date: 2022-03-01
host: x86_64-unknown-linux-gnu