Duplicate major version in lock file causes "failed to select a version" #12079
Labels
A-dependency-resolution
Area: dependency resolution and the resolver
A-diagnostics
Area: Error and warning messages generated by Cargo itself.
C-bug
Category: bug
P-low
Priority: Low
S-needs-design
Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Problem
After rebasing one of my old git branches, I ended up with two
[[package]]
entries in myCargo.lock
file for the same major version. Instead of alerting me that my lock file was invalid, Cargo gave a misleading "failed to select a version" error.Steps
Create a workspace with two packages,
foo
andbar
.Trigger
Cargo.lock
generation.Edit
Cargo.lock
so that it contains two entries forpaste
(this is the part that happened automatically via git):Run
cargo check
or any build command.This is the error I get:
Possible Solution(s)
I'm not familiar with the official definition of the lock file format, but empirically, a normal lock file disambiguates by version number all references to a package whenever there are multiple versions of the same package name. This corrupted lock file does not do that, so it is (I assume) definitely invalid and not merely not-what-is-intended.
Cargo could report this problem instead of proceeding, or it could automatically delete the entry with the lower version (since that will probably be the unintended change accidentally merged from an old branch's lock file state). The latter is consistent with what it would do if
foo
andbar
's lock file entries did have versioned references topaste
.Notes
This is similar to #2302, but evidently the fix for that didn't fix this.
Version
Also reproduces with nightly:
The text was updated successfully, but these errors were encountered: