Skip to content

Package collision in lockfile #413

@rpjohnst

Description

@rpjohnst

🐛 Bug description

I'm building a crate that depends on a local crate twice- once directly and once transitively via another local crate. When I build with wasm-pack, I get an error from Cargo about a package collision in the lockfile. This error does not appear when building with Cargo directly.

🤔 Expected Behavior

The build should succeed.

👟 Steps to reproduce

I've reduced the problem to this directory structure:

wasm-bug/
  main/
    Cargo.toml
    src/lib.rs
  dep_a/
    Cargo.toml
    src/lib.rs
  dep_b/
    Cargo.toml
    src/lib.rs

Here is main/Cargo.toml:

[package]
name = "wasm-bug"
version = "0.1.0"
authors = ["Russell Johnston <[email protected]>"]

[lib]
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2"
dep_a = { path = "../dep_a" }
dep_b = { path = "../dep_b" }

Here is dep_a/Cargo.toml:

[package]
name = "dep_a"
version = "0.1.0"
authors = ["Russell Johnston <[email protected]>"]

[dependencies]
dep_b = { path = "../dep_b" }

Here is dep_b/Cargo.toml:

[package]
name = "dep_b"
version = "0.1.0"
authors = ["Russell Johnston <[email protected]>"]

[dependencies]

The command wasm-pack build (from the wasm-bug/main/ directory) produces this error from Cargo:

error: package collision in the lockfile: packages dep_b v0.1.0 (C:\Users\Russell\Desktop\wasm-bug\main\../dep_b) and dep_b v0.1.0 (C:\Users\Russell\Desktop\wasm-bug\dep_b) are different, but only one can be written to lockfile unambiguously

When I run Cargo directly with cargo build --lib --release --target wasm32-unknown-unknown (taken from wasm-pack.log) the build succeeds.

The bug happens whether or not the crates are part of a workspace. (My original use case has them in a workspace; I removed it as part of the reduced repro above.)

I've also tried the workaround in #380 (comment), since it seemed potentially related, but it did not change things.

🌍 Your environment

wasm-pack version: 0.5.1
cargo version: 1.31.0-nightly (5dbac9888 2018-10-08)

I'm also on Windows, which may be relevant since I haven't tested this on Linux.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions