1CARGO-TREE(1)               General Commands Manual              CARGO-TREE(1)
2
3
4

NAME

6       cargo-tree - Display a tree visualization of a dependency graph
7

SYNOPSIS

9       cargo tree [options]
10

DESCRIPTION

12       This command will display a tree of dependencies to the terminal. An
13       example of a simple project that depends on the "rand" package:
14
15           myproject v0.1.0 (/myproject)
16           `-- rand v0.7.3
17               |-- getrandom v0.1.14
18               |   |-- cfg-if v0.1.10
19               |   `-- libc v0.2.68
20               |-- libc v0.2.68 (*)
21               |-- rand_chacha v0.2.2
22               |   |-- ppv-lite86 v0.2.6
23               |   `-- rand_core v0.5.1
24               |       `-- getrandom v0.1.14 (*)
25               `-- rand_core v0.5.1 (*)
26           [build-dependencies]
27           `-- cc v1.0.50
28
29       Packages marked with (*) have been "de-duplicated". The dependencies
30       for the package have already been shown elsewhere in the graph, and so
31       are not repeated. Use the --no-dedupe option to repeat the duplicates.
32
33       The -e flag can be used to select the dependency kinds to display. The
34       "features" kind changes the output to display the features enabled by
35       each dependency. For example, cargo tree -e features:
36
37           myproject v0.1.0 (/myproject)
38           `-- log feature "serde"
39               `-- log v0.4.8
40                   |-- serde v1.0.106
41                   `-- cfg-if feature "default"
42                       `-- cfg-if v0.1.10
43
44       In this tree, myproject depends on log with the serde feature. log in
45       turn depends on cfg-if with "default" features. When using -e features
46       it can be helpful to use -i flag to show how the features flow into a
47       package. See the examples below for more detail.
48

OPTIONS

50   Tree Options
51       -i spec, --invert spec
52           Show the reverse dependencies for the given package. This flag will
53           invert the tree and display the packages that depend on the given
54           package.
55
56           Note that in a workspace, by default it will only display the
57           package's reverse dependencies inside the tree of the workspace
58           member in the current directory. The --workspace flag can be used
59           to extend it so that it will show the package's reverse
60           dependencies across the entire workspace. The -p flag can be used
61           to display the package's reverse dependencies only with the subtree
62           of the package given to -p.
63
64       --prune spec
65           Prune the given package from the display of the dependency tree.
66
67       --depth depth
68           Maximum display depth of the dependency tree. A depth of 1 displays
69           the direct dependencies, for example.
70
71       --no-dedupe
72           Do not de-duplicate repeated dependencies. Usually, when a package
73           has already displayed its dependencies, further occurrences will
74           not re-display its dependencies, and will include a (*) to indicate
75           it has already been shown. This flag will cause those duplicates to
76           be repeated.
77
78       -d, --duplicates
79           Show only dependencies which come in multiple versions (implies
80           --invert). When used with the -p flag, only shows duplicates within
81           the subtree of the given package.
82
83           It can be beneficial for build times and executable sizes to avoid
84           building that same package multiple times. This flag can help
85           identify the offending packages. You can then investigate if the
86           package that depends on the duplicate with the older version can be
87           updated to the newer version so that only one instance is built.
88
89       -e kinds, --edges kinds
90           The dependency kinds to display. Takes a comma separated list of
91           values:
92
93all — Show all edge kinds.
94
95normal — Show normal dependencies.
96
97build — Show build dependencies.
98
99dev — Show development dependencies.
100
101features — Show features enabled by each dependency. If this is
102               the only kind given, then it will automatically include the
103               other dependency kinds.
104
105no-normal — Do not include normal dependencies.
106
107no-build — Do not include build dependencies.
108
109no-dev — Do not include development dependencies.
110
111no-proc-macro — Do not include procedural macro dependencies.
112
113           The normal, build, dev, and all dependency kinds cannot be mixed
114           with no-normal, no-build, or no-dev dependency kinds.
115
116           The default is normal,build,dev.
117
118       --target triple
119           Filter dependencies matching the given target-triple. The default
120           is the host platform. Use the value all to include all targets.
121
122   Tree Formatting Options
123       --charset charset
124           Chooses the character set to use for the tree. Valid values are
125           "utf8" or "ascii". Default is "utf8".
126
127       -f format, --format format
128           Set the format string for each package. The default is "{p}".
129
130           This is an arbitrary string which will be used to display each
131           package. The following strings will be replaced with the
132           corresponding value:
133
134{p} — The package name.
135
136{l} — The package license.
137
138{r} — The package repository URL.
139
140{f} — Comma-separated list of package features that are enabled.
141
142{lib} — The name, as used in a use statement, of the package's
143               library.
144
145       --prefix prefix
146           Sets how each line is displayed. The prefix value can be one of:
147
148indent (default) — Shows each line indented as a tree.
149
150depth — Show as a list, with the numeric depth printed before
151               each entry.
152
153none — Show as a flat list.
154
155   Package Selection
156       By default, when no package selection options are given, the packages
157       selected depend on the selected manifest file (based on the current
158       working directory if --manifest-path is not given). If the manifest is
159       the root of a workspace then the workspaces default members are
160       selected, otherwise only the package defined by the manifest will be
161       selected.
162
163       The default members of a workspace can be set explicitly with the
164       workspace.default-members key in the root manifest. If this is not set,
165       a virtual workspace will include all workspace members (equivalent to
166       passing --workspace), and a non-virtual workspace will include only the
167       root crate itself.
168
169       -p spec..., --package spec...
170           Display only the specified packages. See cargo-pkgid(1) for the
171           SPEC format. This flag may be specified multiple times and supports
172           common Unix glob patterns like *, ? and []. However, to avoid your
173           shell accidentally expanding glob patterns before Cargo handles
174           them, you must use single quotes or double quotes around each
175           pattern.
176
177       --workspace
178           Display all members in the workspace.
179
180       --exclude SPEC...
181           Exclude the specified packages. Must be used in conjunction with
182           the --workspace flag. This flag may be specified multiple times and
183           supports common Unix glob patterns like *, ? and []. However, to
184           avoid your shell accidentally expanding glob patterns before Cargo
185           handles them, you must use single quotes or double quotes around
186           each pattern.
187
188   Manifest Options
189       --manifest-path path
190           Path to the Cargo.toml file. By default, Cargo searches for the
191           Cargo.toml file in the current directory or any parent directory.
192
193       --frozen, --locked
194           Either of these flags requires that the Cargo.lock file is
195           up-to-date. If the lock file is missing, or it needs to be updated,
196           Cargo will exit with an error. The --frozen flag also prevents
197           Cargo from attempting to access the network to determine if it is
198           out-of-date.
199
200           These may be used in environments where you want to assert that the
201           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
202           network access.
203
204       --offline
205           Prevents Cargo from accessing the network for any reason. Without
206           this flag, Cargo will stop with an error if it needs to access the
207           network and the network is not available. With this flag, Cargo
208           will attempt to proceed without the network if possible.
209
210           Beware that this may result in different dependency resolution than
211           online mode. Cargo will restrict itself to crates that are
212           downloaded locally, even if there might be a newer version as
213           indicated in the local copy of the index. See the cargo-fetch(1)
214           command to download dependencies before going offline.
215
216           May also be specified with the net.offline config value
217           <https://doc.rust-lang.org/cargo/reference/config.html>.
218
219   Feature Selection
220       The feature flags allow you to control which features are enabled. When
221       no feature options are given, the default feature is activated for
222       every selected package.
223
224       See the features documentation
225       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
226       for more details.
227
228       -F features, --features features
229           Space or comma separated list of features to activate. Features of
230           workspace members may be enabled with package-name/feature-name
231           syntax. This flag may be specified multiple times, which enables
232           all specified features.
233
234       --all-features
235           Activate all available features of all selected packages.
236
237       --no-default-features
238           Do not activate the default feature of the selected packages.
239
240   Display Options
241       -v, --verbose
242           Use verbose output. May be specified twice for "very verbose"
243           output which includes extra output such as dependency warnings and
244           build script output. May also be specified with the term.verbose
245           config value
246           <https://doc.rust-lang.org/cargo/reference/config.html>.
247
248       -q, --quiet
249           Do not print cargo log messages. May also be specified with the
250           term.quiet config value
251           <https://doc.rust-lang.org/cargo/reference/config.html>.
252
253       --color when
254           Control when colored output is used. Valid values:
255
256auto (default): Automatically detect if color support is
257               available on the terminal.
258
259always: Always display colors.
260
261never: Never display colors.
262
263           May also be specified with the term.color config value
264           <https://doc.rust-lang.org/cargo/reference/config.html>.
265
266   Common Options
267       +toolchain
268           If Cargo has been installed with rustup, and the first argument to
269           cargo begins with +, it will be interpreted as a rustup toolchain
270           name (such as +stable or +nightly). See the rustup documentation
271           <https://rust-lang.github.io/rustup/overrides.html> for more
272           information about how toolchain overrides work.
273
274       -h, --help
275           Prints help information.
276
277       -Z flag
278           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
279           details.
280

ENVIRONMENT

282       See the reference
283       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
284       for details on environment variables that Cargo reads.
285

EXIT STATUS

2870: Cargo succeeded.
288
289101: Cargo failed to complete.
290

EXAMPLES

292        1. Display the tree for the package in the current directory:
293
294               cargo tree
295
296        2. Display all the packages that depend on the syn package:
297
298               cargo tree -i syn
299
300        3. Show the features enabled on each package:
301
302               cargo tree --format "{p} {f}"
303
304        4. Show all packages that are built multiple times. This can happen if
305           multiple semver-incompatible versions appear in the tree (like
306           1.0.0 and 2.0.0).
307
308               cargo tree -d
309
310        5. Explain why features are enabled for the syn package:
311
312               cargo tree -e features -i syn
313
314           The -e features flag is used to show features. The -i flag is used
315           to invert the graph so that it displays the packages that depend on
316           syn. An example of what this would display:
317
318               syn v1.0.17
319               |-- syn feature "clone-impls"
320               |   `-- syn feature "default"
321               |       `-- rustversion v1.0.2
322               |           `-- rustversion feature "default"
323               |               `-- myproject v0.1.0 (/myproject)
324               |                   `-- myproject feature "default" (command-line)
325               |-- syn feature "default" (*)
326               |-- syn feature "derive"
327               |   `-- syn feature "default" (*)
328               |-- syn feature "full"
329               |   `-- rustversion v1.0.2 (*)
330               |-- syn feature "parsing"
331               |   `-- syn feature "default" (*)
332               |-- syn feature "printing"
333               |   `-- syn feature "default" (*)
334               |-- syn feature "proc-macro"
335               |   `-- syn feature "default" (*)
336               `-- syn feature "quote"
337                   |-- syn feature "printing" (*)
338                   `-- syn feature "proc-macro" (*)
339
340           To read this graph, you can follow the chain for each feature from
341           the root to see why it is included. For example, the "full" feature
342           is added by the rustversion crate which is included from myproject
343           (with the default features), and myproject is the package selected
344           on the command-line. All of the other syn features are added by the
345           "default" feature ("quote" is added by "printing" and "proc-macro",
346           both of which are default features).
347
348           If you're having difficulty cross-referencing the de-duplicated (*)
349           entries, try with the --no-dedupe flag to get the full output.
350

SEE ALSO

352       cargo(1), cargo-metadata(1)
353
354
355
356                                                                 CARGO-TREE(1)
Impressum