Skip to content
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

Bacon fails on a workspace with inter-member dependencies on Windows #59

Closed
jDomantas opened this issue Nov 15, 2021 · 5 comments · Fixed by #60
Closed

Bacon fails on a workspace with inter-member dependencies on Windows #59

jDomantas opened this issue Nov 15, 2021 · 5 comments · Fixed by #60
Labels
bug Something isn't working windows

Comments

@jDomantas
Copy link
Contributor

Reproduction steps:

  1. Create a workspace manifest ./Cargo.toml:

    [workspace]
    members = [
        "crate-a",
        "crate-b",
    ]
  2. Create two member crates:

    cargo new --lib crate-a
    cargo new --lib crate-b
    
  3. Make crate-b depend on crate-a (in ./crate-b/Cargo.toml):

    [package]
    name = "crate-b"
    version = "0.1.0"
    edition = "2018"
    
    [dependencies]
    crate-a = { path = "../crate-a" }
  4. Run bacon in workspace root, or in either of the crate directories. It fails with message:

    Error: `cargo metadata` exited with an error: error: package collision in the lockfile: packages crate-a v0.1.0 (... dir1 ...) and crate-a v0.1.0 (... dir2 ...) are different, but only one can be written to lockfile unambiguously

Meanwhile cargo metadata and cargo check work correctly when ran in any of those 3 directories.

OS: Windows 10
cargo --version: cargo 1.54.0 (5ae8d74b3 2021-06-22)
bacon --version: bacon 1.2.3

@Stargateur
Copy link
Contributor

I got the same

@jDomantas
Copy link
Contributor Author

This seems to be related: rust-lang/cargo#6198

Checked on my machine and the metadata command invoked is

cargo metadata --format-version 1 --manifest-path \\?\C:\Users\<stuff...>\bacon-repro\Cargo.toml

which fails because in the end it does not normalize "bacon-repro/crate-b/../crate-a" to "bacon-repro/crate-a". If I manually invoke metadata with --manifest-path ./Cargo.toml then it works.

@jDomantas
Copy link
Contributor Author

More investigating: it works for me if I remove this canonicalize call. I'm not sure when it is needed - I suppose it changes what Cargo.toml would be resolved in presence of symlinks, but I don't know if that matches other rust tools. I checked what rust-analyzer is doing and it seems that it just uses non-normalized paths. So maybe we can just remove that call?

I guess another option would be to use cargo metadata itself for resolving this, as it also has the logic to find a Cargo.toml somewhere in parent chain. I think you can run it in the directory given to bacon and it will tell you either a package or a workspace it resolved.

@Canop
Copy link
Owner

Canop commented Nov 16, 2021

I'm not answering because at work today but I'm following the investigation with interest.

@Canop
Copy link
Owner

Canop commented Nov 16, 2021

I confirm there doesn't seem to be any problem on linux.

@Canop Canop added bug Something isn't working windows labels Nov 16, 2021
@Canop Canop changed the title Bacon fails on a workspace with inter-member dependencies Bacon fails on a workspace with inter-member dependencies on Windows Nov 16, 2021
@Canop Canop closed this as completed in #60 Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants