Cargo tree invert for optional dependency

I have a dependency which is only used if a non-default feature is activated.

I'd like to see the inverse dependency tree for this package, let's call it foo, using cargo tree, but this does not seem possible?

cargo tree -i -p foo just says: error: package ID specification foo did not match any packages

Intuitively, it seems like cargo tree -i -p foo --all-features should accomplish what I want, but instead I get the following error:
error: cannot specify features for packages outside of workspace. It seems like cargo interprets this command as "enable all features for foo" instead of "enable all features for MY crate/application".

I can find foo in my dependency tree if I run cargo tree --all-features, but using this output to determine WHY foo is included as a dependency is not very user-friendly.

Am I missing something somewhere, or is what I want not actually possible to accomplish with cargo at the moment?

I understand you correctly that you want to show the inverse tree for your dependency foo, right? In that case -p is not the correct flag to use, but just cargo tree -i foo.

Turns out I WAS missing something. Thanks!

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.