blob: 70179add29d326045134ee207f3e6ef144fdcc7c [file] [log] [blame]
Jeff Vander Stoep956d1432020-09-18 13:46:24 +02001'\" t
2.\" Title: cargo-tree
3.\" Author: [see the "AUTHOR(S)" section]
4.\" Generator: Asciidoctor 2.0.10
5.\" Date: 2020-06-25
6.\" Manual: \ \&
7.\" Source: \ \&
8.\" Language: English
9.\"
10.TH "CARGO\-TREE" "1" "2020-06-25" "\ \&" "\ \&"
11.ie \n(.g .ds Aq \(aq
12.el .ds Aq '
13.ss \n[.ss] 0
14.nh
15.ad l
16.de URL
17\fI\\$2\fP <\\$1>\\$3
18..
19.als MTO URL
20.if \n[.g] \{\
21. mso www.tmac
22. am URL
23. ad l
24. .
25. am MTO
26. ad l
27. .
28. LINKSTYLE blue R < >
29.\}
30.SH "NAME"
31cargo\-tree \- Display a tree visualization of a dependency graph
32.SH "SYNOPSIS"
33.sp
34\fBcargo tree [\fIOPTIONS\fP]\fP
35.SH "DESCRIPTION"
36.sp
37This command will display a tree of dependencies to the terminal. An example
38of a simple project that depends on the "rand" package:
39.sp
40.if n .RS 4
41.nf
42myproject v0.1.0 (/myproject)
43`\-\- rand v0.7.3
44 |\-\- getrandom v0.1.14
45 | |\-\- cfg\-if v0.1.10
46 | `\-\- libc v0.2.68
47 |\-\- libc v0.2.68 (*)
48 |\-\- rand_chacha v0.2.2
49 | |\-\- ppv\-lite86 v0.2.6
50 | `\-\- rand_core v0.5.1
51 | `\-\- getrandom v0.1.14 (*)
52 `\-\- rand_core v0.5.1 (*)
53[build\-dependencies]
54`\-\- cc v1.0.50
55.fi
56.if n .RE
57.sp
58Packages marked with \fB(*)\fP have been "de\-duplicated". The dependencies for the
59package have already been shown elswhere in the graph, and so are not
60repeated. Use the \fB\-\-no\-dedupe\fP option to repeat the duplicates.
61.sp
62The \fB\-e\fP flag can be used to select the dependency kinds to display. The
63"features" kind changes the output to display the features enabled by
64each dependency. For example, \fBcargo tree \-e features\fP:
65.sp
66.if n .RS 4
67.nf
68myproject v0.1.0 (/myproject)
69`\-\- log feature "serde"
70 `\-\- log v0.4.8
71 |\-\- serde v1.0.106
72 `\-\- cfg\-if feature "default"
73 `\-\- cfg\-if v0.1.10
74.fi
75.if n .RE
76.sp
77In this tree, \fBmyproject\fP depends on \fBlog\fP with the \fBserde\fP feature. \fBlog\fP in
78turn depends on \fBcfg\-if\fP with "default" features. When using \fB\-e features\fP it
79can be helpful to use \fB\-i\fP flag to show how the features flow into a package.
80See the examples below for more detail.
81.SH "OPTIONS"
82.SS "Tree Options"
83.sp
84\fB\-i\fP \fISPEC\fP, \fB\-\-invert\fP \fISPEC\fP
85.RS 4
86Show the reverse dependencies for the given package. This flag will invert
87the tree and display the packages that depend on the given package.
88.sp
89Note that in a workspace, by default it will only display the package\(cqs
90reverse dependencies inside the tree of the workspace member in the current
91directory. The \fB\-\-workspace\fP flag can be used to extend it so that it will
92show the package\(cqs reverse dependencies across the entire workspace. The \fB\-p\fP
93flag can be used to display the package\(cqs reverse dependencies only with the
94subtree of the package given to \fB\-p\fP.
95.RE
96.sp
97\fB\-\-no\-dedupe\fP
98.RS 4
99Do not de\-duplicate repeated dependencies. Usually, when a package has
100already displayed its dependencies, further occurrences will not
101re\-display its dependencies, and will include a \fB(*)\fP to indicate it has
102already been shown. This flag will cause those duplicates to be repeated.
103.RE
104.sp
105\fB\-d\fP, \fB\-\-duplicates\fP
106.RS 4
107Show only dependencies which come in multiple versions (implies
108\fB\-\-invert\fP). When used with the \fB\-p\fP flag, only shows duplicates within
109the subtree of the given package.
110.sp
111It can be beneficial for build times and executable sizes to avoid building
112that same package multiple times. This flag can help identify the offending
113packages. You can then investigate if the package that depends on the
114duplicate with the older version can be updated to the newer version so that
115only one instance is built.
116.RE
117.sp
118\fB\-e\fP \fIKINDS\fP, \fB\-\-edges\fP \fIKINDS\fP
119.RS 4
120The dependency kinds to display. Takes a comma separated list of values:
121.sp
122.RS 4
123.ie n \{\
124\h'-04'\(bu\h'+03'\c
125.\}
126.el \{\
127. sp -1
128. IP \(bu 2.3
129.\}
130\fBall\fP — Show all edge kinds.
131.RE
132.sp
133.RS 4
134.ie n \{\
135\h'-04'\(bu\h'+03'\c
136.\}
137.el \{\
138. sp -1
139. IP \(bu 2.3
140.\}
141\fBnormal\fP — Show normal dependencies.
142.RE
143.sp
144.RS 4
145.ie n \{\
146\h'-04'\(bu\h'+03'\c
147.\}
148.el \{\
149. sp -1
150. IP \(bu 2.3
151.\}
152\fBbuild\fP — Show build dependencies.
153.RE
154.sp
155.RS 4
156.ie n \{\
157\h'-04'\(bu\h'+03'\c
158.\}
159.el \{\
160. sp -1
161. IP \(bu 2.3
162.\}
163\fBdev\fP — Show development dependencies.
164.RE
165.sp
166.RS 4
167.ie n \{\
168\h'-04'\(bu\h'+03'\c
169.\}
170.el \{\
171. sp -1
172. IP \(bu 2.3
173.\}
174\fBfeatures\fP — Show features enabled by each dependency. If this is
175the only kind given, then it will automatically include the other
176dependency kinds.
177.RE
178.sp
179.RS 4
180.ie n \{\
181\h'-04'\(bu\h'+03'\c
182.\}
183.el \{\
184. sp -1
185. IP \(bu 2.3
186.\}
187\fBno\-normal\fP — Do not include normal dependencies.
188.RE
189.sp
190.RS 4
191.ie n \{\
192\h'-04'\(bu\h'+03'\c
193.\}
194.el \{\
195. sp -1
196. IP \(bu 2.3
197.\}
198\fBno\-build\fP — Do not include build dependencies.
199.RE
200.sp
201.RS 4
202.ie n \{\
203\h'-04'\(bu\h'+03'\c
204.\}
205.el \{\
206. sp -1
207. IP \(bu 2.3
208.\}
209\fBno\-dev\fP — Do not include development dependencies.
210.RE
211.sp
212The \fBno\-\fP prefixed options cannot be mixed with the other dependency kinds.
213.sp
214The default is \fBnormal,build,dev\fP.
215.RE
216.sp
217\fB\-\-target\fP \fITRIPLE\fP
218.RS 4
219Filter dependencies matching the given target\-triple.
220The default is the host platform. Use the value \fBall\fP to include \fBall\fP
221targets.
222.RE
223.SS "Tree Formatting Options"
224.sp
225\fB\-\-charset\fP \fICHARSET\fP
226.RS 4
227Chooses the character set to use for the tree. Valid values are "utf8" or
228"ascii". Default is "utf8".
229.RE
230.sp
231\fB\-f\fP \fIFORMAT\fP, \fB\-\-format\fP \fIFORMAT\fP
232.RS 4
233Set the format string for each package. The default is "{p}".
234.sp
235This is an arbitrary string which will be used to display each package. The following
236strings will be replaced with the corresponding value:
237.sp
238.RS 4
239.ie n \{\
240\h'-04'\(bu\h'+03'\c
241.\}
242.el \{\
243. sp -1
244. IP \(bu 2.3
245.\}
246\fB{p}\fP — The package name.
247.RE
248.sp
249.RS 4
250.ie n \{\
251\h'-04'\(bu\h'+03'\c
252.\}
253.el \{\
254. sp -1
255. IP \(bu 2.3
256.\}
257\fB{l}\fP — The package license.
258.RE
259.sp
260.RS 4
261.ie n \{\
262\h'-04'\(bu\h'+03'\c
263.\}
264.el \{\
265. sp -1
266. IP \(bu 2.3
267.\}
268\fB{r}\fP — The package repository URL.
269.RE
270.sp
271.RS 4
272.ie n \{\
273\h'-04'\(bu\h'+03'\c
274.\}
275.el \{\
276. sp -1
277. IP \(bu 2.3
278.\}
279\fB{f}\fP Comma\-separated list of package features that are enabled.
280.RE
281.RE
282.sp
283\fB\-\-prefix\fP \fIPREFIX\fP
284.RS 4
285Sets how each line is displayed. The \fIPREFIX\fP value can be one of:
286.sp
287.RS 4
288.ie n \{\
289\h'-04'\(bu\h'+03'\c
290.\}
291.el \{\
292. sp -1
293. IP \(bu 2.3
294.\}
295\fBindent\fP (default) — Shows each line indented as a tree.
296.RE
297.sp
298.RS 4
299.ie n \{\
300\h'-04'\(bu\h'+03'\c
301.\}
302.el \{\
303. sp -1
304. IP \(bu 2.3
305.\}
306\fBdepth\fP — Show as a list, with the numeric depth printed before each entry.
307.RE
308.sp
309.RS 4
310.ie n \{\
311\h'-04'\(bu\h'+03'\c
312.\}
313.el \{\
314. sp -1
315. IP \(bu 2.3
316.\}
317\fBnone\fP — Show as a flat list.
318.RE
319.RE
320.SS "Package Selection"
321.sp
322By default, when no package selection options are given, the packages selected
323depend on the selected manifest file (based on the current working directory if
324\fB\-\-manifest\-path\fP is not given). If the manifest is the root of a workspace then
325the workspaces default members are selected, otherwise only the package defined
326by the manifest will be selected.
327.sp
328The default members of a workspace can be set explicitly with the
329\fBworkspace.default\-members\fP key in the root manifest. If this is not set, a
330virtual workspace will include all workspace members (equivalent to passing
331\fB\-\-workspace\fP), and a non\-virtual workspace will include only the root crate itself.
332.sp
333\fB\-p\fP \fISPEC\fP..., \fB\-\-package\fP \fISPEC\fP...
334.RS 4
335Display only the specified packages. See \fBcargo\-pkgid\fP(1) for the
336SPEC format. This flag may be specified multiple times.
337.RE
338.sp
339\fB\-\-workspace\fP
340.RS 4
341Display all members in the workspace.
342.RE
343.sp
344\fB\-\-exclude\fP \fISPEC\fP...
345.RS 4
346Exclude the specified packages. Must be used in conjunction with the
347\fB\-\-workspace\fP flag. This flag may be specified multiple times.
348.RE
349.SS "Manifest Options"
350.sp
351\fB\-\-manifest\-path\fP \fIPATH\fP
352.RS 4
353Path to the \fBCargo.toml\fP file. By default, Cargo searches for the
354\fBCargo.toml\fP file in the current directory or any parent directory.
355.RE
356.SS "Feature Selection"
357.sp
358The feature flags allow you to control the enabled features for the "current"
359package. The "current" package is the package in the current directory, or the
360one specified in \fB\-\-manifest\-path\fP. If running in the root of a virtual
361workspace, then the default features are selected for all workspace members,
362or all features if \fB\-\-all\-features\fP is specified.
363.sp
364When no feature options are given, the \fBdefault\fP feature is activated for
365every selected package.
366.sp
367\fB\-\-features\fP \fIFEATURES\fP
368.RS 4
369Space or comma separated list of features to activate. These features only
370apply to the current directory\(cqs package. Features of direct dependencies
371may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax. This flag may be
372specified multiple times, which enables all specified features.
373.RE
374.sp
375\fB\-\-all\-features\fP
376.RS 4
377Activate all available features of all selected packages.
378.RE
379.sp
380\fB\-\-no\-default\-features\fP
381.RS 4
382Do not activate the \fBdefault\fP feature of the current directory\(cqs
383package.
384.RE
385.SS "Display Options"
386.sp
387\fB\-v\fP, \fB\-\-verbose\fP
388.RS 4
389Use verbose output. May be specified twice for "very verbose" output which
390includes extra output such as dependency warnings and build script output.
391May also be specified with the \fBterm.verbose\fP
392.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
393.RE
394.sp
395\fB\-q\fP, \fB\-\-quiet\fP
396.RS 4
397No output printed to stdout.
398.RE
399.sp
400\fB\-\-color\fP \fIWHEN\fP
401.RS 4
402Control when colored output is used. Valid values:
403.sp
404.RS 4
405.ie n \{\
406\h'-04'\(bu\h'+03'\c
407.\}
408.el \{\
409. sp -1
410. IP \(bu 2.3
411.\}
412\fBauto\fP (default): Automatically detect if color support is available on the
413terminal.
414.RE
415.sp
416.RS 4
417.ie n \{\
418\h'-04'\(bu\h'+03'\c
419.\}
420.el \{\
421. sp -1
422. IP \(bu 2.3
423.\}
424\fBalways\fP: Always display colors.
425.RE
426.sp
427.RS 4
428.ie n \{\
429\h'-04'\(bu\h'+03'\c
430.\}
431.el \{\
432. sp -1
433. IP \(bu 2.3
434.\}
435\fBnever\fP: Never display colors.
436.RE
437.sp
438May also be specified with the \fBterm.color\fP
439.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
440.RE
441.SS "Common Options"
442.sp
443\fB+TOOLCHAIN\fP
444.RS 4
445If Cargo has been installed with rustup, and the first argument to \fBcargo\fP
446begins with \fB+\fP, it will be interpreted as a rustup toolchain name (such
447as \fB+stable\fP or \fB+nightly\fP).
448See the \c
449.URL "https://github.com/rust\-lang/rustup/" "rustup documentation"
450for more information about how toolchain overrides work.
451.RE
452.sp
453\fB\-h\fP, \fB\-\-help\fP
454.RS 4
455Prints help information.
456.RE
457.sp
458\fB\-Z\fP \fIFLAG\fP...
459.RS 4
460Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for
461details.
462.RE
463.sp
464\fB\-\-frozen\fP, \fB\-\-locked\fP
465.RS 4
466Either of these flags requires that the \fBCargo.lock\fP file is
467up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will
468exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from
469attempting to access the network to determine if it is out\-of\-date.
470.sp
471These may be used in environments where you want to assert that the
472\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
473access.
474.RE
475.sp
476\fB\-\-offline\fP
477.RS 4
478Prevents Cargo from accessing the network for any reason. Without this
479flag, Cargo will stop with an error if it needs to access the network and
480the network is not available. With this flag, Cargo will attempt to
481proceed without the network if possible.
482.sp
483Beware that this may result in different dependency resolution than online
484mode. Cargo will restrict itself to crates that are downloaded locally, even
485if there might be a newer version as indicated in the local copy of the index.
486See the \fBcargo\-fetch\fP(1) command to download dependencies before going
487offline.
488.sp
489May also be specified with the \fBnet.offline\fP \c
490.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
491.RE
492.SH "ENVIRONMENT"
493.sp
494See \c
495.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " "
496for
497details on environment variables that Cargo reads.
498.SH "EXIT STATUS"
499.sp
5000
501.RS 4
502Cargo succeeded.
503.RE
504.sp
505101
506.RS 4
507Cargo failed to complete.
508.RE
509.SH "EXAMPLES"
510.sp
511.RS 4
512.ie n \{\
513\h'-04' 1.\h'+01'\c
514.\}
515.el \{\
516. sp -1
517. IP " 1." 4.2
518.\}
519Display the tree for the package in the current directory:
520.sp
521.if n .RS 4
522.nf
523cargo tree
524.fi
525.if n .RE
526.RE
527.sp
528.RS 4
529.ie n \{\
530\h'-04' 2.\h'+01'\c
531.\}
532.el \{\
533. sp -1
534. IP " 2." 4.2
535.\}
536Display all the packages that depend on the \fBsyn\fP package:
537.sp
538.if n .RS 4
539.nf
540cargo tree \-i syn
541.fi
542.if n .RE
543.RE
544.sp
545.RS 4
546.ie n \{\
547\h'-04' 3.\h'+01'\c
548.\}
549.el \{\
550. sp -1
551. IP " 3." 4.2
552.\}
553Show the features enabled on each package:
554.sp
555.if n .RS 4
556.nf
557cargo tree \-\-format "{p} {f}"
558.fi
559.if n .RE
560.RE
561.sp
562.RS 4
563.ie n \{\
564\h'-04' 4.\h'+01'\c
565.\}
566.el \{\
567. sp -1
568. IP " 4." 4.2
569.\}
570Show all packages that are built multiple times. This can happen if multiple
571semver\-incompatible versions appear in the tree (like 1.0.0 and 2.0.0).
572.sp
573.if n .RS 4
574.nf
575cargo tree \-d
576.fi
577.if n .RE
578.RE
579.sp
580.RS 4
581.ie n \{\
582\h'-04' 5.\h'+01'\c
583.\}
584.el \{\
585. sp -1
586. IP " 5." 4.2
587.\}
588Explain why features are enabled for the \fBsyn\fP package:
589.sp
590.if n .RS 4
591.nf
592cargo tree \-e features \-i syn
593.fi
594.if n .RE
595.sp
596The \fB\-e features\fP flag is used to show features. The \fB\-i\fP flag is used to
597invert the graph so that it displays the packages that depend on \fBsyn\fP. An
598example of what this would display:
599.sp
600.if n .RS 4
601.nf
602syn v1.0.17
603|\-\- syn feature "clone\-impls"
604| `\-\- syn feature "default"
605| `\-\- rustversion v1.0.2
606| `\-\- rustversion feature "default"
607| `\-\- myproject v0.1.0 (/myproject)
608| `\-\- myproject feature "default" (command\-line)
609|\-\- syn feature "default" (*)
610|\-\- syn feature "derive"
611| `\-\- syn feature "default" (*)
612|\-\- syn feature "full"
613| `\-\- rustversion v1.0.2 (*)
614|\-\- syn feature "parsing"
615| `\-\- syn feature "default" (*)
616|\-\- syn feature "printing"
617| `\-\- syn feature "default" (*)
618|\-\- syn feature "proc\-macro"
619| `\-\- syn feature "default" (*)
620`\-\- syn feature "quote"
621 |\-\- syn feature "printing" (*)
622 `\-\- syn feature "proc\-macro" (*)
623.fi
624.if n .RE
625.sp
626To read this graph, you can follow the chain for each feature from the root to
627see why it is included. For example, the "full" feature is added by the
628\fBrustversion\fP crate which is included from \fBmyproject\fP (with the default
629features), and \fBmyproject\fP is the package selected on the command\-line. All
630of the other \fBsyn\fP features are added by the "default" feature ("quote" is
631added by "printing" and "proc\-macro", both of which are default features).
632.sp
633If you\(cqre having difficulty cross\-referencing the de\-duplicated \fB(*)\fP entries,
634try with the \fB\-\-no\-dedupe\fP flag to get the full output.
635.RE
636.SH "SEE ALSO"
637.sp
638\fBcargo\fP(1), \fBcargo\-metadata\fP(1)