-
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 update -p SPEC
can silently downgrade dependencies of other packages when multi-major ranges are used
#5529
Comments
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 |
@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 |
Here you go: wsdown.zip |
I can reproduce! Thanks! Now to investigate. |
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:
So the issue is not that sort, it is where is the |
@Eh2406 correct yeah, when Cargo reads a lock file it'll re-resolve with a lot of |
Ok so there is a bug in that code, (what part is it particularly?) Because the lockfile claims that |
Oh dear, that does sound like a problem! I'm not entirely sure where that'd come from... |
@Eh2406 FWIW the locking pieces are all roughly around here. I'm not sure how much you've had a chance to explore |
I tried running with Some hilites (or may be not. I may miss reading as I don't know
^ That looks like it may be where we ignore the lock file.
^ 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? |
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 |
That heuristic is at cargo/src/cargo/core/registry.rs Lines 564 to 567 in cc11d50
We don't do minimization when generating the lockfile, why do we do it for update? |
Oh we always try to minimize the lock file but it depends what you visit first. If you first see 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" |
cargo update -p SPEC
can silently downgrade dependencies of other packagescargo update -p SPEC
can silently downgrade dependencies of other packages when multi-major ranges are used
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:
cargo update
will generate a lockfile that looks good (a
→0.9,b
→1.0,c
→1.0).cargo update -p c
will downgradeb
'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:
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.The text was updated successfully, but these errors were encountered: