"Package collision in lockfile" using UNC/root local device/etc paths #6198
Description
Problem
When invoking Cargo with the current directory or manifest path given as one of Windows' more "exotic" kinds of paths, such as a \\?\
"root local device path," internal path comparisons can fail and the build aborts. Ideally, Cargo would be able to handle these paths.
Steps
One way to reproduce the bug is with a directory structure like this:
bug/
main/
Cargo.toml
src/lib.rs
dep_a/
Cargo.toml
src/lib.rs
dep_b/
Cargo.toml
src/lib.rs
main
depends, via path = "../dep_a"
and path = "../dep_b"
, on both dep_a
and dep_b
. dep_a
also depends, via path = "../dep_b"
, on dep_b
.
Here is a zip file containing the structure described above: path-bug.zip
Then, the bug can be triggered by running this command:
cargo build --manifest-path \\?\C:\full\path\to\bug\main\Cargo.toml
It produces an error message like this:
error: package collision in the lockfile: packages dep_b v0.1.0 (C:\full\path\to\bug\main\../dep_b) and dep_b v0.1.0 (C:\full\path\to\bug\dep_b) are different, but only one can be written to lockfile unambigiously
wasm-pack
hits this issue because it sets the current directory to a canonicalized .
when invoking Cargo. See rustwasm/wasm-pack#380, rustwasm/wasm-pack#413, and an attempt to work around this problem in rustwasm/wasm-pack#389.
Notes
I most recently reproduced this with Cargo version cargo 1.31.0-nightly (5dbac9888 2018-10-08)
, on Windows 10.