uv tree: Show the Dependency Tree
uv tree renders the project dependency tree from uv.lock so you can see what pulls in what.
uv tree answers "why is this package installed?" by showing the resolved graph. It reads the lockfile, so it reflects exactly what uv sync would install.
What it does
uv tree displays the resolved dependency graph as an indented tree. --invert flips it so you start from a leaf and see what depends on it, which is how you trace why a transitive package is present.
Common usage
uv tree
uv tree --depth 1
uv tree --package httpx
uv tree --invert --package certifi
uv tree --no-devOptions
| Flag | What it does |
|---|---|
| --depth <n> | Limit how deep the tree is printed |
| --package <name> | Show the subtree for one package |
| --invert | Show reverse dependencies (what needs this) |
| --no-dev | Exclude the dev group from the tree |
| --outdated | Annotate packages that have newer releases |
In CI
uv tree --outdated is a lightweight way to surface stale dependencies in a scheduled job. Because it reads uv.lock without resolving, it is fast and deterministic; cache $UV_CACHE_DIR only matters if it has to fetch metadata for --outdated.
Common errors in CI
"error: Unable to find lockfile" means no uv.lock exists; run uv lock first. "error: Package <name> not found in the project environment" from --package means a typo or a package only present under a group you excluded. --outdated needs network access; behind a firewall it errors fetching index metadata.