Giter Club home page Giter Club logo

Comments (3)

weihanglo avatar weihanglo commented on August 27, 2024

Haven't checked what is wrong, but here is the minimal repo in Cargo-flavored test code:

#[cargo_test]
fn git_downgrade_with_duplicate_packages() {
    Package::new("rustc-hash", "1.1.0").publish();
    Package::new("rustc-hash", "2.0.0").publish();
    let (git_project, repo) = git::new_repo("pubgrub", |project| {
        project
            .file(
                "Cargo.toml",
                r#"
                    [package]
                    name = "pubgrub"
                    edition = "2021"

                    [dependencies]
                    rustc-hash = ">=1.0.0, <3.0.0"
                "#,
            )
            .file("src/lib.rs", "")
    });
    let rev1 = repo.revparse_single("HEAD").unwrap().id();
    let p = project()
        .file(
            "Cargo.toml",
            &format!(
                r#"
                    [package]
                    name = "foo"

                    [dependencies]
                    rustc-hash1 = {{ version = "1", package = "rustc-hash" }}
                    rustc-hash2 = {{ version = "2", package = "rustc-hash" }}
                    pubgrub = {{ git = "{}", rev = "{rev1}" }}
                "#,
                git_project.url(),
            ),
        )
        .file("src/lib.rs", "")
        .build();

    p.cargo("fetch").run();

    assert_e2e().eq(p.read_lockfile(), str![[r##"
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "foo"
version = "0.0.0"
dependencies = [
 "pubgrub",
 "rustc-hash 1.1.0",
 "rustc-hash 2.0.0",
]

[[package]]
name = "pubgrub"
version = "0.0.0"
source = "git+[ROOTURL]/pubgrub?rev=de416b2ad7717e09e79a34de70330a07c8b9a0fb#de416b2ad7717e09e79a34de70330a07c8b9a0fb"
dependencies = [
 "rustc-hash 2.0.0",
]

[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1981f6ee594df09828a9d95ce56ebac0ee354f40d684bec2f14bd3f4e54356a3"

[[package]]
name = "rustc-hash"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bff208de0b08da920f89e127a4a0f70d2053783efc65d9e398907d1e127cda41"

"##]]);

    git_project.change_file("src/lib.rs", "pub fn hello()");
    git::add(&repo);
    let rev2 = git::commit(&repo);

    p.change_file(
        "Cargo.toml",
        &format!(
            r#"
                [package]
                name = "foo"

                [dependencies]
                rustc-hash1 = {{ version = "1", package = "rustc-hash" }}
                rustc-hash2 = {{ version = "2", package = "rustc-hash" }}
                pubgrub = {{ git = "{}", rev = "{rev2}" }}
            "#,
            git_project.url(),
        ),
    );

    p.cargo("fetch").run();

    assert_e2e().eq(p.read_lockfile(), str![[r##"
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "foo"
version = "0.0.0"
dependencies = [
 "pubgrub",
 "rustc-hash 1.1.0",
 "rustc-hash 2.0.0",
]

[[package]]
name = "pubgrub"
version = "0.0.0"
source = "git+[ROOTURL]/pubgrub?rev=b5883bacc43c4055a9b1261f77f0c4dd9c2ceae3#b5883bacc43c4055a9b1261f77f0c4dd9c2ceae3"
dependencies = [
 "rustc-hash 1.1.0",
]

[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1981f6ee594df09828a9d95ce56ebac0ee354f40d684bec2f14bd3f4e54356a3"

[[package]]
name = "rustc-hash"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bff208de0b08da920f89e127a4a0f70d2053783efc65d9e398907d1e127cda41"

"##]]);
}

This seems to only happen with Git dependencies. Editing a registry dependency with a wide version requirement doesn't have the same buggy behavior.

from cargo.

ehuss avatar ehuss commented on August 27, 2024

I suspect this is similar to #5529. I don't remember the explanation why when there is a dependency range across multiple major semver versions that the resolver tends to downgrade to older versions.

from cargo.

epage avatar epage commented on August 27, 2024

I suspect this is related to #14115.

from cargo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.