Skip to content
Latchkey

cargo tree: Usage, Options & Common CI Errors

Visualize and query the dependency graph.

cargo tree shows the full dependency tree for your package. Its inverted (-i) and duplicate (-d) modes are the fastest way to understand why a crate or a specific version is in your build.

What it does

Reads the resolved graph and prints it as an indented tree. Filters let you focus on a single package, find duplicate versions, or trace which dependency introduced something.

Common usage

Terminal
cargo tree                        # full tree
cargo tree -i openssl-sys         # who depends on this crate
cargo tree -d                     # show duplicate versions
cargo tree -e features            # show feature edges
cargo tree --target x86_64-unknown-linux-gnu

Common CI error: duplicate version conflict

A build breaks because two incompatible major versions of a crate are linked (common with -sys crates). Run cargo tree -d to list duplicates, then cargo tree -i <crate> to find the dependency forcing the old version, and bump or unify it.

Options

FlagEffect
-i, --invert <pkg>Show reverse dependencies
-d, --duplicatesList crates with multiple versions
-e, --edges <kinds>Filter edge kinds (e.g. features)
--target <triple>Resolve for a target

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →