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-gnuCommon 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
| Flag | Effect |
|---|---|
| -i, --invert <pkg> | Show reverse dependencies |
| -d, --duplicates | List crates with multiple versions |
| -e, --edges <kinds> | Filter edge kinds (e.g. features) |
| --target <triple> | Resolve for a target |
Related guides
cargo update: Usage, Options & Common CI Errorscargo update changes Cargo.lock to newer dependency versions. Learn -p to update one crate, --precise to pin,…
cargo add: Usage, Options & Common CI Errorscargo add edits Cargo.toml to add a dependency, with --features, --dev, and --optional. Learn the syntax and…
Rust "cargo build failed" - Diagnose the Build Failure in CIFix a failing "cargo build" in CI -- a compile error, a missing native dependency, or a transient registry fe…