cargo-tree

Display the dependency graph as a tree

TLDR

Show dependency tree
$ cargo tree
Show inverted tree for package
$ cargo tree --invert [package]
Show duplicate dependencies
$ cargo tree --duplicates
Show features enabled by dependencies
$ cargo tree --edges features
Show without deduplication
$ cargo tree --no-dedupe
Show specific package subtree
$ cargo tree -p [package]
ASCII output
$ cargo tree --charset ascii

SYNOPSIS

cargo tree [options]

DESCRIPTION

cargo tree displays a tree visualization of the dependency graph for a Rust project. It shows all packages and their transitive dependencies in an indented tree format, with packages marked `(*)` indicating they have already been shown elsewhere and are deduplicated.The command supports several analysis modes: `--invert` traces which packages depend on a given crate, `--duplicates` shows packages that appear multiple times with different versions, and `--edges features` reveals how features propagate through the dependency graph. Built into Cargo since Rust 1.44, it replaced the earlier `cargo-tree` third-party plugin.

PARAMETERS

-i, --invert spec

Invert tree, showing what depends on package
-p, --package spec
Package to use as tree root
-e, --edges kinds
Dependency types: normal, dev, build, features, all
-d, --duplicates
Show packages built multiple times
--no-dedupe
Don't deduplicate repeated packages
--depth n
Maximum display depth
--prune spec
Prune packages from display
--charset set
Character set: utf8, ascii
--format fmt
Format string for package display
--prefix prefix
Prefix: indent, depth, none
--target triple
Filter for target platform
--all-features
Enable all features
--features features
Enable specific features

OUTPUT SYMBOLS

**(*)** Package already shown elsewhere (deduplicated)

INSTALL

sudo apt install cargo
sudo dnf install cargo
sudo apk add cargo
sudo zypper install cargo
nix profile install nixpkgs#cargo

CAVEATS

Use --invert to trace where a dependency comes from. Combine with --edges features to understand feature propagation.

SEE ALSO

cargo(1), cargo-metadata(1)

RESOURCES

Source code · Documentation