Show *feature* dependancy graph

i was trying to use bevy on NixOS when i got a build error from alsa-sys. i figured the easiest workaround would be to just disable sound, since i don't need it right now. after manually specifying every default feature except bevy_audio, i reran it.. and still got the same alsa-sys error.

cargo tree -ialsa-sys showed that bevy_internal is still pulling in bevy_audio, but it wasn't clear why.

is there a way to show a tree of which features enable which other features?

I believe you want cargo tree --edges features, documented as:

1 Like

that is indeed what i want, although there seems to be a bug in its logic, it shows "default" as the feature flag, even when i have default-features = false.

Try cargo-hackerman, cargo hackerman explain alsa-sys will draw a feature level tree (needs xdot) starting from alsa-sys and going up each feature until it reaches your workspace.

2 Likes

This probably means something else in your dependency tree is depending on default. What's the contents of your Cargo.toml?

1 Like

it doesn't have any dependancies other than bevy. i think it's just a bug in cargo (cargo tree doesn't actually use the same resolver logic as the rest of cargo, which can lead to inaccuracies. i'm guessing noone though to test cargo tree --edges features with disabling the default feature, but then re-enabling some of the defaults)

One of the default features is vorbis which depends on bevy_internal/vorbis which depends on bevy_audio/vorbis. Another is android_shared_stdcxx which activates bevy_internal/android_shared_stdcxx which depends on bevy_audio/android_shared_stdcxx.

And this is what cargo tree prints for me with those features enabled:

$ cargo tree -i alsa-sys --edges features

alsa-sys v0.3.1
└── alsa-sys feature "default"
    └── alsa v0.9.0
        └── alsa feature "default"
            └── cpal v0.15.3
                └── cpal feature "default"
                    └── rodio v0.17.3
                        └── bevy_audio v0.13.2
                            ├── bevy_audio feature "android_shared_stdcxx"
                            │   └── bevy_internal feature "android_shared_stdcxx"
                            │       └── bevy feature "android_shared_stdcxx"
-------------------- [snip] --------------------
                            ├── bevy_audio feature "default"
                            │   └── bevy_internal v0.13.2
                            │       └── bevy v0.13.2
-------------------- [snip] --------------------
                            │       ├── bevy_internal feature "bevy_audio"
                            │       │   ├── bevy_internal feature "android_shared_stdcxx" (*)
                            │       │   └── bevy_internal feature "vorbis"
                            │       │       └── bevy feature "vorbis" (*)
-------------------- [snip] --------------------
                            └── bevy_audio feature "vorbis"
                                └── bevy_internal feature "vorbis" (*)
                        ├── rodio feature "lewton"
                        │   └── rodio feature "vorbis"
                        │       └── bevy_audio feature "vorbis" (*)
                        └── rodio feature "vorbis" (*)

(As a side note, bevy should probably be updated to use ? syntax for dependency features, so that android_shared_stdcxx would not unconditionally activate bevy_audio.)

1 Like

The buggy-seeming part is everything I snipped out of this sub-tree:

├── bevy_audio feature "default"
│   └── bevy_internal v0.13.2
│       └── bevy v0.13.2
│           ├── bevy feature "android_shared_stdcxx" (*)
│           ├── bevy feature "animation"
│           │   └── dps v0.1.0 (/home/mbrubeck/src/tmp/dps) (*)
│           ├── bevy feature "bevy_animation"
│           │   └── dps v0.1.0 (/home/mbrubeck/src/tmp/dps) (*)
│           │   └── bevy feature "animation" (*)
│           ├── bevy feature "bevy_asset"
│           │   └── dps v0.1.0 (/home/mbrubeck/src/tmp/dps) (*)
...

This apparently happens because bevy_internal depends on bevy_audio without disabling its default features, so bevy audio feature "default" is attributed to the bevy_internal package itself, while it would be more useful to attribute it only to bevy_internal feature "bevy_audio".

1 Like

what cargo version? i'm on a recent nightly, so there's a chance this is a regression.

1 Like

I get identical output on stable cargo 1.79.0 and cargo 1.81.0-nightly (a1f47ec3f 2024-06-15).

My Cargo.toml has:

[dependencies]
bevy = { version = "0.13.2", default-features = false, features = [
"android_shared_stdcxx", "animation", "bevy_animation", "bevy_asset",
"bevy_core_pipeline", "bevy_debug_stepping", "bevy_gilrs", "bevy_gizmos",
"bevy_gltf", "bevy_pbr", "bevy_render", "bevy_scene", "bevy_sprite",
"bevy_text", "bevy_ui", "bevy_winit", "default_font", "hdr", "ktx2",
"multi-threaded", "png", "tonemapping_luts", "vorbis", "webgl2", "x11",
"zstd"
] }
1 Like

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.