Cargo fails to compile a crate if it's included multiple times at different paths #8639
Labels
A-dependency-resolution
Area: dependency resolution and the resolver
A-lockfile
Area: Cargo.lock issues
C-bug
Category: bug
S-needs-team-input
Status: Needs input from team on whether/how to proceed.
Problem
Cargo fails to compile a crate if it is dependent on a crate that is included multiple times at different paths. For example, you have crate
a
which depends on cratesb
andc
. Both cratesb
andc
depend on crated
but each includes it from a different path.The error shown is:
This scenario manifests when you recursively include crates as git submodules and a single crate is indirectly included multiple times as a sub dependency (same crate, same version, different paths).
Steps
I've attached a bash script that can reproduce this issue automatically (see note # 3). It's short enough that it can also serve as a step-by-step guide for reproducing the issue manually. The steps needed to reproduce the bug are:
Possible Solution(s)
I'm not privy to Cargo's internals unfortunately. Sorry.
Notes
git
directive (instead ofpath
) is not an option due to the way our project is structured.rustc
handles this issue correctly: if the duplicate crates are identical, they are compiled without issue. If they differ,rustc
asks for them to be differentiated appart by using-C metadata=...
. This opens up the possibility of using rustc together with GNU make as a workaround, but I'd rather continue using Cargo instead.rustc
handles the issue when used directly.Output of
cargo version
: cargo 1.45.1 (f242df6 2020-07-22)Host Platform : x86_64-unknown-linux-gnu
Attachments
The text was updated successfully, but these errors were encountered: