Rust dependency graphs can hide why a crate is present, why two versions are built, or which feature pulled optional code into a build. cargo tree reads Cargo's resolved package graph and prints the relationships that matter when a manifest, lockfile, or feature selection needs inspection.
The tree reflects Cargo's resolver output rather than only the dependency lines typed in Cargo.toml. A (*) marker means Cargo has already printed that package or feature subtree elsewhere, so repeated branches stay compact.
A package or workspace member directory with an existing Cargo.toml is the expected starting point. In workspaces, add --workspace when reverse-dependency checks need every member instead of only the package subtree selected by the current directory.
The directory should contain the package Cargo.toml file, or a workspace manifest that includes the package being inspected.
$ cargo tree
demo-cli v0.1.0 (/work/demo-cli)
└── serde_json v1.0.150
├── indexmap v2.14.0
│ ├── equivalent v1.0.2
│ └── hashbrown v0.17.1
├── itoa v1.0.18
├── memchr v2.8.2
├── serde_core v1.0.228
└── zmij v1.0.21
The default tree includes normal, build, and dev dependencies for the selected package graph. If the first run downloads crates, rerun the command after Cargo finishes resolving the lockfile for a quieter tree.
$ cargo tree --invert itoa
itoa v1.0.18
└── serde_json v1.0.150
└── demo-cli v0.1.0 (/work/demo-cli)
Replace itoa with the crate name that needs a dependency path. Add --workspace in a workspace when the reverse tree should include every member.
$ cargo tree --duplicates warning: nothing to print. To find dependencies that require specific target platforms, try to use option `--target all` first, and then narrow your search scope accordingly.
A warning that nothing printed means Cargo did not find duplicate versions in the selected graph. Use --target all when target-specific dependencies may be outside the host platform graph.
$ cargo tree --edges features --invert serde_json
serde_json v1.0.150
├── serde_json feature "default"
│ └── demo-cli v0.1.0 (/work/demo-cli)
│ └── demo-cli feature "default" (command-line)
├── serde_json feature "indexmap"
│ └── serde_json feature "preserve_order"
│ └── demo-cli v0.1.0 (/work/demo-cli) (*)
├── serde_json feature "preserve_order" (*)
└── serde_json feature "std"
├── serde_json feature "default" (*)
└── serde_json feature "preserve_order" (*)
The feature tree shows that the project enabled preserve_order, which activates indexmap through serde_json.