LinuxCommandLibrary

cargo-tree

Display the dependency graph as a tree

TLDR

Show dependency tree

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

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)

CAVEATS

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

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community