jplatte / cargo-depgraph

Creates graphviz dependency graphs for Rust projects that use Cargo
GNU General Public License v3.0
151 stars 8 forks source link

Allow removing disabled optional dependencies from graph #24

Closed johnbchron closed 2 months ago

johnbchron commented 2 months ago

I have a use-case where I'm trying to debug usages of my crates that vary wildly (100s of packages) in size given different feature usages. Right now it seems that even if I use --no-default-features and --features [feature], I can't get optional but disabled dependencies removed from the graph, so it's pretty unreadable. See attached. When analyzed with the same features, cargo tree only shows 20ish packages.

jplatte commented 2 months ago

I'm not sure whether the cargo metadata output has the required information to support this, but I can try to figure that out.

johnbchron commented 2 months ago

Basically I'd just like to remove packages connected with just a dotted line.

jplatte commented 2 months ago

Yeah I get that. I just tested on one repo and it works for me. Thinking more about it, you might be hitting https://github.com/rust-lang/cargo/issues/7754. Is this in the context of a cargo workspace with more than one package in it? Can you try commenting out the other workspace member entries?

johnbchron commented 2 months ago

It works if I disable the other workspace members and if I make the graph for a crate that doesn't depend on any other crates in the workspace.

jplatte commented 2 months ago

Right, in that case it is that bug I linked, and there is nothing cargo-depgraph can do, short of hacks that temporarily edit the toml files / create updated copies in a tempdir.

Even then, that would likely only be a partial fix, so I don't think it's reasonable to put that much work in.

I hope the workaround is good enough for your use case.