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)

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.