Unavoidable Cargo.lock package collision occurs if path dependencies share same name and version #10353
Labels
A-lockfile
Area: Cargo.lock issues
S-needs-team-input
Status: Needs input from team on whether/how to proceed.
Problem
If you find yourself with dependencies on two packages with the same name, you can normally include dependencies on both by renaming the dependencies. However, if these packages are included via path dependencies and both have the same version, then
cargo generate-lockfile
will fail with a package collision error. This occurs even when the dependencies are renamed to avoid collision.Steps
cargo init /tmp/foo
cargo init --lib /tmp/foo/dir1/pkg
cargo init --lib /tmp/foo/dir2/pkg
Cargo.toml
infoo
to include bothpkg
crates as dependencies, renaming to avoid conflictcargo generate-lockfile
infoo
and observe package collision despite rename.Possible Solution(s)
It appears the
Cargo.lock
file only tracks the package name and version for path dependencies. For other dependencies, additional information appears to be included. For example, with agit
dependency mixed with a crates.io dependency:the dependencies in
foo
are distinguished by theirsource
in theCargo.lock
file:Inclusion of a
source
for path dependencies could help differentiate in the that case.Notes
If the version is changed for one of the
pkg
crates to a different version than the other, then the lock file is generated successfully:Version
The text was updated successfully, but these errors were encountered: