Skip to content
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 update -p SPEC can silently downgrade dependencies of other packages when multi-major ranges are used #5529

Open
ehuss opened this issue May 13, 2018 · 13 comments · May be fixed by #14582
Labels
A-dependency-resolution Area: dependency resolution and the resolver Command-update S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@ehuss
Copy link
Contributor

ehuss commented May 13, 2018

This is kinda convoluted, but it bit me when I wasn't paying attention when updating rust's lock file. Here's a relatively small repro. Create a workspace with the following members and dependencies:

a → bitflags="0.9"
b → bitflags=">= 0.9, < 2.0"
c → bitflags="1.0"

cargo update will generate a lockfile that looks good (a→0.9, b→1.0, c→1.0).

cargo update -p c will downgrade b's copy of bitflags to 0.9! I'd expect it to leave it as-is.

The real-world example of this is in rust where these chains exist:

rustbook → ... → html5ever → .. → rand 0.3
rls → rayon → rayon-core → rand >=0.3, < 0.5
cargo → ... → rand 0.4

Updating cargo caused rayon's version of rand to downgrade. I didn't use rand in my example above because version 0.3 is a little odd in that it also depends on rand 0.4, but doesn't seem to be important and just complicates the example.

@alexcrichton
Copy link
Member

I believe this is sort of an instance of #2064, given multiple valid resolution graphs Cargo doesn't necessarily guarantee which one is generated. Otherwise Cargo doesn't currently have a heuristic to minimize the number of major versions resolved to

@Eh2406
Copy link
Contributor

Eh2406 commented Jul 10, 2018

@ehuss Thank you for the cleare example, if it is easy for you do you have a zip file or a repo of this test case? If not I can stop being lazy and make one for myself.

I suspect we are trying things that are in self.try_to_use out of order, but I'd need to dig in to find out why.

@ehuss
Copy link
Contributor Author

ehuss commented Jul 10, 2018

Here you go: wsdown.zip

@Eh2406
Copy link
Contributor

Eh2406 commented Jul 10, 2018

I can reproduce! Thanks! Now to investigate.

@Eh2406
Copy link
Contributor

Eh2406 commented Jul 10, 2018

I added some prints after that sort

        print!("{}:{} => <", dep.name(), dep.version_req());
        for i in &ret {
            print!("{}, ", i.summary.version());
        }
        println!(">");

then in the unzipped folder:

issues5529> ..\cargo\target\release\cargo.exe  update -p c -Z no-index-update
bitflags:= 0.9.1 => <0.9.1, >
bitflags:^1.0 => <1.0.3, 1.0.2, 1.0.1, 1.0.0, >

So the issue is not that sort, it is where is the =0.9.1 version_req coming from. It is not from any of the Cargo.toml's. So it must be inferred from the lock file, (@alexcrichton is that a thing that happens?) and it must inferred incorrectly as the lock file is supposed to keep c depending on 1.0.3.

@alexcrichton
Copy link
Member

@Eh2406 correct yeah, when Cargo reads a lock file it'll re-resolve with a lot of =0.9.1 dependencies and such, so if you cargo update -p foo it'll do a "conservative update" of foo but try to not tamper with the rest of the dependency graph.

@Eh2406
Copy link
Contributor

Eh2406 commented Jul 11, 2018

Ok so there is a bug in that code, (what part is it particularly?) Because the lockfile claims that b should depend on 1.0.3 but then it adds a =0.9.1 requirement.

@alexcrichton
Copy link
Member

Oh dear, that does sound like a problem! I'm not entirely sure where that'd come from...

@alexcrichton
Copy link
Member

@Eh2406 FWIW the locking pieces are all roughly around here. I'm not sure how much you've had a chance to explore core/registry.rs but that's where a good deal of the lockfile logic happens instead of the resolver itself

@Eh2406
Copy link
Contributor

Eh2406 commented Jul 11, 2018

I tried running with set RUST_LOG=trace

Some hilites (or may be not. I may miss reading as I don't know core/registry.rs):

DEBUG 2018-07-11T18:48:12Z: cargo::ops::resolve: ignoring any lock pointing directly at c v0.1.0 (file:///.../issues5529/c)
DEBUG 2018-07-11T18:48:12Z: cargo::ops::resolve: ignoring any lock pointing directly at bitflags v1.0.3

^ That looks like it may be where we ignore the lock file.

TRACE 2018-07-11T18:48:12Z: cargo::core::registry: locking summary of a v0.1.0 (file:///.../issues5529/a)
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      bitflags/^0.9/registry `https://github.com/rust-lang/crates.io-index`
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      first hit on bitflags v0.9.1
TRACE 2018-07-11T18:48:12Z: cargo::core::dependency: locking dep from `bitflags` with `^0.9` at registry `https://github.com/rust-lang/crates.io-index` to bitflags v0.9.1
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: locking summary of b v0.1.0 (file:///.../issues5529/b)
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      bitflags/>= 0.9, < 2.0/registry `https://github.com/rust-lang/crates.io-index`
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      second hit on bitflags v0.9.1
TRACE 2018-07-11T18:48:12Z: cargo::core::dependency: locking dep from `bitflags` with `>= 0.9, < 2.0` at registry `https://github.com/rust-lang/crates.io-index` to bitflags v0.9.1

^ That looks like it may be where lock the dep from b to the wrong thing.

issues5529>set RUST_LOG=trace
issues5529>..\cargo\target\debug\cargo.exe update -p c -Z no-index-update
TRACE 2018-07-11T18:48:11Z: cargo::util::toml: read_manifest; path=C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\Cargo.toml; source-id=file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529
DEBUG 2018-07-11T18:48:11Z: cargo::core::workspace: find_root - is root C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\Cargo.toml
DEBUG 2018-07-11T18:48:11Z: cargo::core::workspace: find_members - C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\a\Cargo.toml
TRACE 2018-07-11T18:48:11Z: cargo::util::toml: read_manifest; path=C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\a\Cargo.toml; source-id=file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a
DEBUG 2018-07-11T18:48:11Z: cargo::core::workspace: find_members - C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\b\Cargo.toml
TRACE 2018-07-11T18:48:11Z: cargo::util::toml: read_manifest; path=C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\b\Cargo.toml; source-id=file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b
DEBUG 2018-07-11T18:48:11Z: cargo::core::workspace: find_members - C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\c\Cargo.toml
TRACE 2018-07-11T18:48:11Z: cargo::util::toml: read_manifest; path=C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\c\Cargo.toml; source-id=file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c
DEBUG 2018-07-11T18:48:11Z: cargo::core::workspace: find_members - C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\Cargo.toml
DEBUG 2018-07-11T18:48:11Z: cargo::core::workspace: find_root - trying C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\Cargo.toml
DEBUG 2018-07-11T18:48:12Z: cargo::core::workspace: find_root - found a root checking exclusion
DEBUG 2018-07-11T18:48:12Z: cargo::core::workspace: find_root - found!
DEBUG 2018-07-11T18:48:12Z: cargo::core::workspace: find_root - trying C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\Cargo.toml
DEBUG 2018-07-11T18:48:12Z: cargo::core::workspace: find_root - found a root checking exclusion
DEBUG 2018-07-11T18:48:12Z: cargo::core::workspace: find_root - found!
DEBUG 2018-07-11T18:48:12Z: cargo::core::workspace: find_root - trying C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\Cargo.toml
DEBUG 2018-07-11T18:48:12Z: cargo::core::workspace: find_root - found a root checking exclusion
DEBUG 2018-07-11T18:48:12Z: cargo::core::workspace: find_root - found!
DEBUG 2018-07-11T18:48:12Z: cargo::core::workspace: find_root - is root C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\Cargo.toml
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: load/missing  file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: loading source file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c
DEBUG 2018-07-11T18:48:12Z: cargo::sources::config: loading: file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c
TRACE 2018-07-11T18:48:12Z: cargo::core::source::source_id: loading SourceId; file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c
TRACE 2018-07-11T18:48:12Z: cargo::ops::cargo_read_manifest: read_package; path=C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\c\Cargo.toml; source-id=file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c
TRACE 2018-07-11T18:48:12Z: cargo::util::toml: read_manifest; path=C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\c\Cargo.toml; source-id=file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c
TRACE 2018-07-11T18:48:12Z: cargo::ops::resolve: previous: graph: Graph {
  - c v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c)
    - bitflags v1.0.3
  - bitflags v0.9.1
  - b v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b)
    - bitflags v1.0.3
  - a v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a)
    - bitflags v0.9.1
  - bitflags v1.0.3
}

features: {
}
DEBUG 2018-07-11T18:48:12Z: cargo::ops::resolve: ignoring any lock pointing directly at c v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c)
DEBUG 2018-07-11T18:48:12Z: cargo::ops::resolve: ignoring any lock pointing directly at bitflags v1.0.3
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: register_lock: bitflags v0.9.1
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: register_lock: b v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b)
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: register_lock: a v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a)
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      -> bitflags v0.9.1
DEBUG 2018-07-11T18:48:12Z: cargo::ops::resolve: attempting to prefer bitflags v0.9.1
DEBUG 2018-07-11T18:48:12Z: cargo::ops::resolve: attempting to prefer b v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b)
DEBUG 2018-07-11T18:48:12Z: cargo::ops::resolve: attempting to prefer a v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a)
DEBUG 2018-07-11T18:48:12Z: cargo::ops::resolve: attempting to prefer bitflags v1.0.3
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: load/missing  file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: loading source file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a
DEBUG 2018-07-11T18:48:12Z: cargo::sources::config: loading: file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a
TRACE 2018-07-11T18:48:12Z: cargo::core::source::source_id: loading SourceId; file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a
TRACE 2018-07-11T18:48:12Z: cargo::ops::cargo_read_manifest: read_package; path=C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\a\Cargo.toml; source-id=file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a
TRACE 2018-07-11T18:48:12Z: cargo::util::toml: read_manifest; path=C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\a\Cargo.toml; source-id=file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: load/missing  file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: loading source file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b
DEBUG 2018-07-11T18:48:12Z: cargo::sources::config: loading: file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b
TRACE 2018-07-11T18:48:12Z: cargo::core::source::source_id: loading SourceId; file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b
TRACE 2018-07-11T18:48:12Z: cargo::ops::cargo_read_manifest: read_package; path=C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\b\Cargo.toml; source-id=file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b
TRACE 2018-07-11T18:48:12Z: cargo::util::toml: read_manifest; path=C:\Users\finkelman.SEMCOGDOM\Documents\MyProjects\cargo_speed_test\issues5529\b\Cargo.toml; source-id=file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: load/locked   file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: locking summary of a v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a)
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      bitflags/^0.9/registry `https://github.com/rust-lang/crates.io-index`
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      first hit on bitflags v0.9.1
TRACE 2018-07-11T18:48:12Z: cargo::core::dependency: locking dep from `bitflags` with `^0.9` at registry `https://github.com/rust-lang/crates.io-index` to bitflags v0.9.1
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: locking summary of b v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b)
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      bitflags/>= 0.9, < 2.0/registry `https://github.com/rust-lang/crates.io-index`
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      second hit on bitflags v0.9.1
TRACE 2018-07-11T18:48:12Z: cargo::core::dependency: locking dep from `bitflags` with `>= 0.9, < 2.0` at registry `https://github.com/rust-lang/crates.io-index` to bitflags v0.9.1
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: locking summary of c v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c)
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      bitflags/^1.0/registry `https://github.com/rust-lang/crates.io-index`
TRACE 2018-07-11T18:48:12Z: cargo::core::registry:      nope, unlocked
DEBUG 2018-07-11T18:48:12Z: cargo::core::resolver: initial activation: a v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a)
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: activating a v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a)
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: load/missing  registry `https://github.com/rust-lang/crates.io-index`
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: loading source registry `https://github.com/rust-lang/crates.io-index`
DEBUG 2018-07-11T18:48:12Z: cargo::sources::config: loading: registry `https://github.com/rust-lang/crates.io-index`
TRACE 2018-07-11T18:48:12Z: cargo::core::source::source_id: loading SourceId; registry `https://github.com/rust-lang/crates.io-index`
DEBUG 2018-07-11T18:48:12Z: cargo::sources::registry: skipping update due to locked registry
DEBUG 2018-07-11T18:48:12Z: cargo::sources::registry: attempting query without update
TRACE 2018-07-11T18:48:12Z: cargo::sources::registry::remote: opened a repo without a lock
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: locking summary of bitflags v0.9.1
DEBUG 2018-07-11T18:48:12Z: cargo::core::resolver: initial activation: b v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b)
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: activating b v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b)
DEBUG 2018-07-11T18:48:12Z: cargo::core::resolver: initial activation: c v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c)
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: activating c v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c)
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: load/mismatch registry `https://github.com/rust-lang/crates.io-index`
DEBUG 2018-07-11T18:48:12Z: cargo::core::registry: loading source registry `https://github.com/rust-lang/crates.io-index`
DEBUG 2018-07-11T18:48:12Z: cargo::sources::config: loading: registry `https://github.com/rust-lang/crates.io-index`
TRACE 2018-07-11T18:48:12Z: cargo::core::source::source_id: loading SourceId; registry `https://github.com/rust-lang/crates.io-index`
TRACE 2018-07-11T18:48:12Z: cargo::sources::registry::remote: opened a repo without a lock
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: locking summary of bitflags v1.0.0
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: locking summary of bitflags v1.0.1
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: locking summary of bitflags v1.0.2
TRACE 2018-07-11T18:48:12Z: cargo::core::registry: locking summary of bitflags v1.0.3
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: a[0]>bitflags 1 candidates
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: a[0]>bitflags 0 prev activations
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: a[0]>bitflags trying 0.9.1
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: activating bitflags v0.9.1
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: b[0]>bitflags 1 candidates
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: b[0]>bitflags 1 prev activations
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: b[0]>bitflags trying 0.9.1
DEBUG 2018-07-11T18:48:12Z: cargo::core::resolver::context: checking if bitflags v0.9.1 is already activated
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: c[0]>bitflags 4 candidates
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: c[0]>bitflags 1 prev activations
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: c[0]>bitflags trying 1.0.3
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: activating bitflags v1.0.3
TRACE 2018-07-11T18:48:12Z: cargo::core::resolver: resolved: graph: Graph {
  - bitflags v1.0.3
  - c v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c)
    - bitflags v1.0.3
  - b v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b)
    - bitflags v0.9.1
  - bitflags v0.9.1
  - a v0.1.0 (file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a)
    - bitflags v0.9.1
}

features: {
  bitflags v1.0.3: {"default"}
  bitflags v0.9.1: {"example_generated", "default"}
}
DEBUG 2018-07-11T18:48:12Z: cargo::ops::cargo_generate_lockfile: {
    (
        "a",
        SourceId {
            inner: SourceIdInner {
                url: "file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a",
                canonical_url: "file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/a",
                kind: Path,
                precise: None,
                name: None
            }
        }
    ): (
        [],
        []
    ),
    (
        "b",
        SourceId {
            inner: SourceIdInner {
                url: "file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b",
                canonical_url: "file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/b",
                kind: Path,
                precise: None,
                name: None
            }
        }
    ): (
        [],
        []
    ),
    (
        "bitflags",
        SourceId {
            inner: SourceIdInner {
                url: "https://github.com/rust-lang/crates.io-index",
                canonical_url: "https://github.com/rust-lang/crates.io-index",
                kind: Registry,
                precise: Some(
                    "locked"
                ),
                name: None
            }
        }
    ): (
        [],
        []
    ),
    (
        "c",
        SourceId {
            inner: SourceIdInner {
                url: "file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c",
                canonical_url: "file:///C:/Users/finkelman.SEMCOGDOM/Documents/MyProjects/cargo_speed_test/issues5529/c",
                kind: Path,
                precise: None,
                name: None
            }
        }
    ): (
        [],
        []
    )
}
 INFO 2018-07-11T18:48:12Z: cargo::util::job::imp: found 0 remaining processes

Dose that help track it down?

@alexcrichton
Copy link
Member

Oh yeah that'd do it! When you attempt to update something we remove locks in the graph that would otherwise possible cause a complete resolution failure, so in this case we're actually coalescing the number of bitflags deps from 2 to 1 which Cargo has a heuristic for. (in that this looks like expected behavior)

@Eh2406
Copy link
Contributor

Eh2406 commented Jul 11, 2018

That heuristic is at

// If this dependency did not have a locked version, then we query
// all known locked packages to see if they match this dependency.
// If anything does then we lock it to that and move on.
let v = locked

We don't do minimization when generating the lockfile, why do we do it for update?
Furthermore with the "conservative update" feature the resolver will try to continue using things that are in the lockfile. I think what I am asking is Is there a real case where we get a better answer with the heuristic then we get from the conservative update alone?

@alexcrichton
Copy link
Member

Oh we always try to minimize the lock file but it depends what you visit first. If you first see >= 0.9, < 2.0 you'll select 1.0. Only later when you see ^0.9 do you realize you're forced to use two versions. If you see them in the other order, however, you'll only use 0.9 series.

The heuristic for a minimal lockfile is in general just one added to help guide resolution but it's just affecting sorting I believe rather than the actual generated lockfile. I think it depends on the situation which crate graph is considered "more desirable"

Eh2406 added a commit to Eh2406/cargo that referenced this issue Jul 17, 2018
@epage epage added A-dependency-resolution Area: dependency resolution and the resolver S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. labels Oct 19, 2023
@epage epage changed the title cargo update -p SPEC can silently downgrade dependencies of other packages cargo update -p SPEC can silently downgrade dependencies of other packages when multi-major ranges are used Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependency-resolution Area: dependency resolution and the resolver Command-update S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
4 participants