Deptree Command
Synopsis
dnf5 [GLOBAL OPTIONS] deptree [OPTIONS] <package-spec>...
Description
deptree displays a package dependency graph using enabled repository metadata
by default. With --installed, it uses packages from the local RPMDB instead.
It does not invoke the dependency solver.
By default, dependencies of type Requires are followed. Requirements with a
single provider link directly to that provider. Requirements with multiple
providers are displayed below a choice: node. rpmlib(*) requirements are
ignored. Requirements with no provider are displayed as unsatisfied: nodes.
Each package subtree is expanded once across all selected roots, at an occurrence
whose dependency depth is minimal from any root. Other occurrences with a subtree
are marked with [expanded elsewhere], even if the expansion appears later in
the output or under another root. Leaf nodes are not marked. This prevents cycles
and repeated subtree expansion.
Dependencies retain their metadata order within each requested type. Provider candidates and reverse dependents are sorted by NEVRA. Rich-expression operands retain their expression order.
Package specifications accept package names, NEVRAs, and glob patterns. For an
ambiguous specification without an architecture, the command selects the latest
EVR for each matching architecture. Dependency providers and reverse dependents
follow the same policy. --arch limits roots and traversal to the specified
architectures. Use --showduplicates to retain all matching versions. An
architecture-qualified NEVRA is honored as written.
In repository mode, repository selection follows the standard global options,
including --repo, --enable-repo, and --disable-repo.
Options
--reverse- Show packages that depend on each selected package. Reverse traversal uses the latest EVR of each package name and architecture by default.
--flat- Print a sorted, deduplicated list of package NEVRAs instead of a tree.
--installed- Display dependency trees for installed packages only.
--contains-pkgs=PACKAGE_NAME,...- Show only branches leading to packages with specified names. This is a list option; package-name globs are supported. A matching package is retained as a leaf, along with all shortest paths from a selected root to it. Each matching package is considered separately. Dependency levels are counted as for
--depth. --arch=ARCH[,ARCH...]- Limit roots, provider candidates, and reverse dependents to the specified architectures. This option can be specified multiple times.
--depth=N- Include packages reachable within
Ndependency levels from any selected root.0prints only roots. Only package nodes count toward dependency depth; choice, condition, else, requirement, and unsatisfied nodes add no depth. Shared package subtrees are expanded only at their minimum depth, keeping displayed branches withinNpackage levels. --show-requires- Render explicit
requirement:nodes between packages and their providers. This option applies only to forward traversal and conflicts with--reverse. --types=LIST- Process the comma-separated dependency types in
LIST. Accepted values arerequires,recommends,suggests,supplements, andenhances. The default isrequires. --showduplicates- Include every matching package EVR. Without this option, ambiguous roots and traversal candidates use the latest EVR per name/architecture.
--json- Print machine-readable JSON. Normal mode emits a graph with
roots,nodes, andedgesarrays. Combined with--flat, it emits a sorted JSON array of NEVRA strings.
JSON Output
dnf5 deptree --json <package-spec>
Without --flat, the command returns a graph object with these fields:
roots(array of strings): IDs of root package nodes.nodes(array of objects): each graph node appears once. Every node has anidandtype.packagenodes containname,epoch,version,release, andarch(all strings). Their IDs begin withpkg:.choicenodes containcapability(string). Their IDs begin withchoice:.conditionalnodes containcondition(string). Their IDs begin withcond:.elsenodes containcondition(string). Their IDs begin withelse:.requirementnodes, produced by--show-requires, containcapability(string). Their IDs begin withrequirement:.unsatisfiednodes contain the unresolvedcapability(string). Their IDs begin withunsatisfied:.
edges(array of objects): graph links withsourceandtargetnode IDs. Every edge containsrequirements, an array of capability strings. It is empty for graph-structure links and provider links.
dnf5 deptree --flat --json <package-spec>
With both --flat and --json, the command returns a sorted JSON array of
unique package NEVRA strings. All non-package nodes, including unsatisfied
requirements, are omitted.
Examples
dnf5 deptree libsolv- Show dependencies of the newest matching
libsolvpackage builds. dnf5 deptree --reverse dnf5- Show packages in enabled repositories that depend on matching
dnf5package builds. dnf5 deptree --showduplicates --depth=1 'libsolv*'- Show every matching
libsolvbuild and one dependency level. dnf5 deptree --types=requires,recommends --json bash- Emit a JSON dependency graph that includes both hard and recommended dependencies.
dnf5 deptree --contains-pkgs='DeepDependencyB*' packageA- Show only shortest dependency paths from
packageAthat reach matching packages.