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

Moving repository to a virtual manifest can cause surprising dependency resolution errors due to resolver fallback #11811

Closed
thomaseizinger opened this issue Mar 8, 2023 · 2 comments

Comments

@thomaseizinger
Copy link

I am not entirely sure this is a bug report or a feature request but I'll describe anyway what happened.

We have a fairly large workspace over at https://github.com/libp2p/rust-libp2p. Previously, the root Cargo.toml was both a crate and a workspace manifest. For various reasons, I wanted to move away from that.

That root crate is edition = 2021 which implies the new dependency resolver (version 2). Thus, we did not specify resolver = 2 explicitly as part of the [workspace] table. We need the new feature resolver because we have some target-specific features to activiate:

https://github.com/libp2p/rust-libp2p/blob/7069d78ee333c92a3b99bbad100d9c6ba2fe361a/transports/noise/Cargo.toml#L26-L30

What happened now is that by splitting the root manifest into a separate crate, the edition = 2021 disappeared and cargo was now falling back using v1 of the resolver, resulting in a failing build because the features of the snow dependency within the Cargo.toml of libp2p-noise were incorrectly merged.

This was especially surprising because I was running cargo build --package libp2p which does have edition = 2021. I guess this could be considered a bug? I am not sure.

The problem was fixed by explicitly specifying resolver = 2 in the [workspace] table.

Here is the PR: libp2p/rust-libp2p#3536

@thomaseizinger thomaseizinger changed the title Moving repository to a virtual manifest can cause surprising dependency resolution errors Moving repository to a virtual manifest can cause surprising dependency resolution errors due to resolver fallback Mar 8, 2023
@weihanglo
Copy link
Member

weihanglo commented Mar 8, 2023

Thanks for the report. This is a known inconvenience we want to address, by either better documentation or hint or automation. See this comment for more #9996 (comment).

Also, see these related issues and pull requests below. Some of them has been stale for a while. I'll appreciate if anyone could continue driving them.


This was especially surprising because I was running cargo build --package libp2p which does have edition = 2021. I guess this could be considered a bug? I am not sure.

If you're under a workspace running that, it will respect workspace settings. That means without resolver = "2" it is still running with resolver v1.

@ehuss
Copy link
Contributor

ehuss commented Mar 8, 2023

Closing as a duplicate of the above linked issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants