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

ENVIRONMENT

268       See the reference
269       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
270       for details on environment variables that Cargo reads.
271

EXIT STATUS

273       ·  0: Cargo succeeded.
274
275       ·  101: Cargo failed to complete.
276

EXAMPLES

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

SEE ALSO

338       cargo(1), cargo-metadata(1)
339
340
341
342                                                                 CARGO-TREE(1)
Impressum