Why would `cargo tree -d` show duplicates of the exact same crate version?

e.g. my current cargo tree -d gives me

cargo tree -d
warning: Patch `spirv-builder v0.4.0-alpha.12 (https://github.com/EmbarkStudios/rust-gpu?rev=eeb67ae#eeb67ae7)` was not used in the crate graph.
Patch `spirv-std v0.4.0-alpha.12 (https://github.com/EmbarkStudios/rust-gpu?rev=eeb67ae#eeb67ae7)` was not used in the crate graph.
Patch `spirv-std-macros v0.4.0-alpha.12 (https://github.com/EmbarkStudios/rust-gpu?rev=eeb67ae#eeb67ae7)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
getrandom v0.2.3
ā””ā”€ā”€ uuid v0.8.2
    ā”œā”€ā”€ bevy_reflect_derive v0.5.0 (proc-macro) (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5)
    ā”‚   ā””ā”€ā”€ bevy_reflect v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5)
    ā”‚       ā”œā”€ā”€ bevy_app v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5)
    ā”‚       ā”‚   ā””ā”€ā”€ patina-utils v0.0.0 (D:\repos\cad97\gamedev\crates\patina-utils)
    ā”‚       ā”‚       ā”œā”€ā”€ patina v0.0.0 (D:\repos\cad97\gamedev\crates\patina)
    ā”‚       ā”‚       ā”‚   ā””ā”€ā”€ demos v0.0.0 (D:\repos\cad97\gamedev\crates\demos)
    ā”‚       ā”‚       ā””ā”€ā”€ patina-backend v0.0.0 (D:\repos\cad97\gamedev\crates\patina-backend)
    ā”‚       ā”‚           ā””ā”€ā”€ patina v0.0.0 (D:\repos\cad97\gamedev\crates\patina) (*)
    ā”‚       ā”œā”€ā”€ bevy_ecs v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5)
    ā”‚       ā”‚   ā”œā”€ā”€ bevy_app v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
    ā”‚       ā”‚   ā””ā”€ā”€ patina-utils v0.0.0 (D:\repos\cad97\gamedev\crates\patina-utils) (*)
    ā”‚       ā””ā”€ā”€ patina-utils v0.0.0 (D:\repos\cad97\gamedev\crates\patina-utils) (*)
    ā”œā”€ā”€ bevy_utils v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5)
    ā”‚   ā”œā”€ā”€ bevy_app v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
    ā”‚   ā”œā”€ā”€ bevy_ecs v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
    ā”‚   ā””ā”€ā”€ bevy_reflect v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
    ā””ā”€ā”€ patina-utils v0.0.0 (D:\repos\cad97\gamedev\crates\patina-utils) (*)

getrandom v0.2.3
ā”œā”€ā”€ ahash v0.7.4
ā”‚   ā”œā”€ā”€ bevy_utils v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
ā”‚   ā”œā”€ā”€ hashbrown v0.11.2
ā”‚   ā”‚   ā”œā”€ā”€ gpu-descriptor v0.2.2 (https://github.com/zakarumych/gpu-descriptor?rev=98463d6#98463d63)
ā”‚   ā”‚   ā”‚   ā””ā”€ā”€ wgpu-hal v0.10.7
ā”‚   ā”‚   ā”‚       ā”œā”€ā”€ wgpu v0.10.2
ā”‚   ā”‚   ā”‚       ā”‚   ā”œā”€ā”€ patina v0.0.0 (D:\repos\cad97\gamedev\crates\patina) (*)
ā”‚   ā”‚   ā”‚       ā”‚   ā””ā”€ā”€ patina-backend v0.0.0 (D:\repos\cad97\gamedev\crates\patina-backend) (*)
ā”‚   ā”‚   ā”‚       ā””ā”€ā”€ wgpu-core v0.10.4
ā”‚   ā”‚   ā”‚           ā””ā”€ā”€ wgpu v0.10.2 (*)
ā”‚   ā”‚   ā””ā”€ā”€ patina-utils v0.0.0 (D:\repos\cad97\gamedev\crates\patina-utils) (*)
ā”‚   ā””ā”€ā”€ patina-utils v0.0.0 (D:\repos\cad97\gamedev\crates\patina-utils) (*)
ā””ā”€ā”€ rand_core v0.6.3
    ā”œā”€ā”€ rand v0.8.4
    ā”‚   ā”œā”€ā”€ bevy_ecs v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
    ā”‚   ā””ā”€ā”€ patina-utils v0.0.0 (D:\repos\cad97\gamedev\crates\patina-utils) (*)
    ā””ā”€ā”€ rand_chacha v0.3.1
        ā””ā”€ā”€ rand v0.8.4 (*)

hashbrown v0.11.2 (*)

hashbrown v0.11.2
ā””ā”€ā”€ indexmap v1.7.0
    ā”œā”€ā”€ patina-utils v0.0.0 (D:\repos\cad97\gamedev\crates\patina-utils) (*)
    ā””ā”€ā”€ toml v0.5.8
        ā””ā”€ā”€ cargo-manifest v0.2.6
            ā””ā”€ā”€ bevy_macro_utils v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5)
                ā”œā”€ā”€ bevy_derive v0.5.0 (proc-macro) (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5)
                ā”‚   ā”œā”€ā”€ bevy_app v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
                ā”‚   ā””ā”€ā”€ bevy_utils v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
                ā”œā”€ā”€ bevy_ecs_macros v0.5.0 (proc-macro) (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5)
                ā”‚   ā””ā”€ā”€ bevy_ecs v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
                ā””ā”€ā”€ bevy_reflect_derive v0.5.0 (proc-macro) (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)

serde v1.0.130
ā”œā”€ā”€ bevy_ecs v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
ā”œā”€ā”€ bevy_reflect v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
ā”œā”€ā”€ erased-serde v0.3.16
ā”‚   ā””ā”€ā”€ bevy_reflect v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
ā”œā”€ā”€ patina-utils v0.0.0 (D:\repos\cad97\gamedev\crates\patina-utils) (*)
ā”œā”€ā”€ serde_json v1.0.68
ā”‚   ā””ā”€ā”€ tracing-subscriber v0.2.24
ā”‚       ā”œā”€ā”€ patina v0.0.0 (D:\repos\cad97\gamedev\crates\patina) (*)
ā”‚       ā””ā”€ā”€ tracing-error v0.1.2
ā”‚           ā”œā”€ā”€ color-eyre v0.5.11
ā”‚           ā”‚   ā””ā”€ā”€ patina v0.0.0 (D:\repos\cad97\gamedev\crates\patina) (*)
ā”‚           ā”œā”€ā”€ color-spantrace v0.1.6
ā”‚           ā”‚   ā””ā”€ā”€ color-eyre v0.5.11 (*)
ā”‚           ā””ā”€ā”€ patina v0.0.0 (D:\repos\cad97\gamedev\crates\patina) (*)
ā”œā”€ā”€ smallvec v1.7.0
ā”‚   ā”œā”€ā”€ bevy_reflect v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
ā”‚   ā”œā”€ā”€ parking_lot_core v0.8.5
ā”‚   ā”‚   ā””ā”€ā”€ parking_lot v0.11.2
ā”‚   ā”‚       ā”œā”€ā”€ bevy_reflect v0.5.0 (https://github.com/bevyengine/bevy?rev=42409fc#42409fc5) (*)
ā”‚   ā”‚       ā”œā”€ā”€ wgpu v0.10.2 (*)
ā”‚   ā”‚       ā”œā”€ā”€ wgpu-core v0.10.4 (*)
ā”‚   ā”‚       ā”œā”€ā”€ wgpu-hal v0.10.7 (*)
ā”‚   ā”‚       ā””ā”€ā”€ winit v0.25.0
ā”‚   ā”‚           ā”œā”€ā”€ patina v0.0.0 (D:\repos\cad97\gamedev\crates\patina) (*)
ā”‚   ā”‚           ā””ā”€ā”€ patina-backend v0.0.0 (D:\repos\cad97\gamedev\crates\patina-backend) (*)
ā”‚   ā”œā”€ā”€ patina-utils v0.0.0 (D:\repos\cad97\gamedev\crates\patina-utils) (*)
ā”‚   ā”œā”€ā”€ tracing-subscriber v0.2.24 (*)
ā”‚   ā”œā”€ā”€ wgpu v0.10.2 (*)
ā”‚   ā””ā”€ā”€ wgpu-core v0.10.4 (*)
ā”œā”€ā”€ tracing-serde v0.1.2
ā”‚   ā””ā”€ā”€ tracing-subscriber v0.2.24 (*)
ā””ā”€ā”€ tracing-subscriber v0.2.24 (*)

serde v1.0.130
ā”œā”€ā”€ cargo-manifest v0.2.6 (*)
ā”œā”€ā”€ toml v0.5.8 (*)
ā””ā”€ā”€ uuid v0.8.2 (*)

where getrandom v0.2.3 is listed as duplicated (with getrandom v0.2.3), as well as hashbrown v0.11.2 and serde v1.0.130.

I am using a small patch table

[patch.crates-io]
[patch.crates-io]

# rust-gpu
spirv-builder = { git = "https://github.com/EmbarkStudios/rust-gpu", rev="eeb67ae" }
spirv-std = { git = "https://github.com/EmbarkStudios/rust-gpu", rev="eeb67ae" }
spirv-std-macros = { git = "https://github.com/EmbarkStudios/rust-gpu", rev="eeb67ae" }

# bevy
bevy_app = { git = "https://github.com/bevyengine/bevy", rev="42409fc" }
bevy_ecs = { git = "https://github.com/bevyengine/bevy", rev="42409fc" }
bevy_reflect = { git = "https://github.com/bevyengine/bevy", rev="42409fc" }
bevy_tasks = { git = "https://github.com/bevyengine/bevy", rev="42409fc" }
bevy_utils = { git = "https://github.com/bevyengine/bevy", rev="42409fc" }

# to dedupe hashbrown:0.9
gpu-descriptor = { git = "https://github.com/zakarumych/gpu-descriptor", rev="98463d6" }

but none of these crates are patched, and the output says that just the normal vX.Y.Z version is being used, not a path/git/etc alternate source.

> cargo tree --version
cargo 1.56.0-beta (18751dd3f 2021-09-01)
1 Like

If you are using v2 of cargo's resolver it might be compiling multiple copies of the same crate because one version is used at build time with feature set A and the same version is used at runtime with feature set B.

3 Likes

cargo tree -e features may help diagnosing this.

2 Likes

That's certainly going to be it!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.