blob: 52ad5808f060ffb158058f52017abb93bb7cd843 [file] [log] [blame]
Jeff Vander Stoep956d1432020-09-18 13:46:24 +02001'\" t
2.\" Title: cargo-metadata
3.\" Author: [see the "AUTHOR(S)" section]
4.\" Generator: Asciidoctor 2.0.10
5.\" Date: 2020-07-04
6.\" Manual: \ \&
7.\" Source: \ \&
8.\" Language: English
9.\"
10.TH "CARGO\-METADATA" "1" "2020-07-04" "\ \&" "\ \&"
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\-metadata \- Machine\-readable metadata about the current package
32.SH "SYNOPSIS"
33.sp
34\fBcargo metadata [\fIOPTIONS\fP]\fP
35.SH "DESCRIPTION"
36.sp
37Output JSON to stdout containing information about the workspace members and
38resolved dependencies of the current package.
39.sp
40It is recommended to include the \fB\-\-format\-version\fP flag to future\-proof
41your code to ensure the output is in the format you are expecting.
42.sp
43See the \c
44.URL "https://crates.io/crates/cargo_metadata" "cargo_metadata crate"
45for a Rust API for reading the metadata.
46.SH "OUTPUT FORMAT"
47.sp
48The output has the following format:
49.sp
50.if n .RS 4
51.nf
52{
53 /* Array of all packages in the workspace.
54 It also includes all feature\-enabled dependencies unless \-\-no\-deps is used.
55 */
56 "packages": [
57 {
58 /* The name of the package. */
59 "name": "my\-package",
60 /* The version of the package. */
61 "version": "0.1.0",
62 /* The Package ID, a unique identifier for referring to the package. */
63 "id": "my\-package 0.1.0 (path+file:///path/to/my\-package)",
64 /* The license value from the manifest, or null. */
65 "license": "MIT/Apache\-2.0",
66 /* The license\-file value from the manifest, or null. */
67 "license_file": "LICENSE",
68 /* The description value from the manifest, or null. */
69 "description": "Package description.",
70 /* The source ID of the package. This represents where
71 a package is retrieved from.
72 This is null for path dependencies and workspace members.
73 For other dependencies, it is a string with the format:
74 \- "registry+URL" for registry\-based dependencies.
75 Example: "registry+https://github.com/rust\-lang/crates.io\-index"
76 \- "git+URL" for git\-based dependencies.
77 Example: "git+https://github.com/rust\-lang/cargo?rev=5e85ba14aaa20f8133863373404cb0af69eeef2c#5e85ba14aaa20f8133863373404cb0af69eeef2c"
78 */
79 "source": null,
80 /* Array of dependencies declared in the package\(aqs manifest. */
81 "dependencies": [
82 {
83 /* The name of the dependency. */
84 "name": "bitflags",
85 /* The source ID of the dependency. May be null, see
86 description for the package source.
87 */
88 "source": "registry+https://github.com/rust\-lang/crates.io\-index",
89 /* The version requirement for the dependency.
90 Dependencies without a version requirement have a value of "*".
91 */
92 "req": "^1.0",
93 /* The dependency kind.
94 "dev", "build", or null for a normal dependency.
95 */
96 "kind": null,
97 /* If the dependency is renamed, this is the new name for
98 the dependency as a string. null if it is not renamed.
99 */
100 "rename": null,
101 /* Boolean of whether or not this is an optional dependency. */
102 "optional": false,
103 /* Boolean of whether or not default features are enabled. */
104 "uses_default_features": true,
105 /* Array of features enabled. */
106 "features": [],
107 /* The target platform for the dependency.
108 null if not a target dependency.
109 */
110 "target": "cfg(windows)",
111 /* A string of the URL of the registry this dependency is from.
112 If not specified or null, the dependency is from the default
113 registry (crates.io).
114 */
115 "registry": null
116 }
117 ],
118 /* Array of Cargo targets. */
119 "targets": [
120 {
121 /* Array of target kinds.
122 \- lib targets list the `crate\-type` values from the
123 manifest such as "lib", "rlib", "dylib",
124 "proc\-macro", etc. (default ["lib"])
125 \- binary is ["bin"]
126 \- example is ["example"]
127 \- integration test is ["test"]
128 \- benchmark is ["bench"]
129 \- build script is ["custom\-build"]
130 */
131 "kind": [
132 "bin"
133 ],
134 /* Array of crate types.
135 \- lib and example libraries list the `crate\-type` values
136 from the manifest such as "lib", "rlib", "dylib",
137 "proc\-macro", etc. (default ["lib"])
138 \- all other target kinds are ["bin"]
139 */
140 "crate_types": [
141 "bin"
142 ],
143 /* The name of the target. */
144 "name": "my\-package",
145 /* Absolute path to the root source file of the target. */
146 "src_path": "/path/to/my\-package/src/main.rs",
147 /* The Rust edition of the target.
148 Defaults to the package edition.
149 */
150 "edition": "2018",
151 /* Array of required features.
152 This property is not included if no required features are set.
153 */
154 "required\-features": ["feat1"],
155 /* Whether or not this target has doc tests enabled, and
156 the target is compatible with doc testing.
157 */
158 "doctest": false
159 }
160 ],
161 /* Set of features defined for the package.
162 Each feature maps to an array of features or dependencies it
163 enables.
164 */
165 "features": {
166 "default": [
167 "feat1"
168 ],
169 "feat1": [],
170 "feat2": []
171 },
172 /* Absolute path to this package\(aqs manifest. */
173 "manifest_path": "/path/to/my\-package/Cargo.toml",
174 /* Package metadata.
175 This is null if no metadata is specified.
176 */
177 "metadata": {
178 "docs": {
179 "rs": {
180 "all\-features": true
181 }
182 }
183 },
184 /* List of registries to which this package may be published.
185 Publishing is unrestricted if null, and forbidden if an empty array. */
186 "publish": [
187 "crates\-io"
188 ],
189 /* Array of authors from the manifest.
190 Empty array if no authors specified.
191 */
192 "authors": [
193 "Jane Doe <user@example.com>"
194 ],
195 /* Array of categories from the manifest. */
196 "categories": [
197 "command\-line\-utilities"
198 ],
199 /* Array of keywords from the manifest. */
200 "keywords": [
201 "cli"
202 ],
203 /* The readme value from the manifest or null if not specified. */
204 "readme": "README.md",
205 /* The repository value from the manifest or null if not specified. */
206 "repository": "https://github.com/rust\-lang/cargo",
207 /* The default edition of the package.
208 Note that individual targets may have different editions.
209 */
210 "edition": "2018",
211 /* Optional string that is the name of a native library the package
212 is linking to.
213 */
214 "links": null,
215 }
216 ],
217 /* Array of members of the workspace.
218 Each entry is the Package ID for the package.
219 */
220 "workspace_members": [
221 "my\-package 0.1.0 (path+file:///path/to/my\-package)",
222 ],
223 // The resolved dependency graph for the entire workspace. The enabled
224 // features are based on the enabled features for the "current" package.
225 // Inactivated optional dependencies are not listed.
226 //
227 // This is null if \-\-no\-deps is specified.
228 //
229 // By default, this includes all dependencies for all target platforms.
230 // The `\-\-filter\-platform` flag may be used to narrow to a specific
231 // target triple.
232 "resolve": {
233 /* Array of nodes within the dependency graph.
234 Each node is a package.
235 */
236 "nodes": [
237 {
238 /* The Package ID of this node. */
239 "id": "my\-package 0.1.0 (path+file:///path/to/my\-package)",
240 /* The dependencies of this package, an array of Package IDs. */
241 "dependencies": [
242 "bitflags 1.0.4 (registry+https://github.com/rust\-lang/crates.io\-index)"
243 ],
244 /* The dependencies of this package. This is an alternative to
245 "dependencies" which contains additional information. In
246 particular, this handles renamed dependencies.
247 */
248 "deps": [
249 {
250 /* The name of the dependency\(aqs library target.
251 If this is a renamed dependency, this is the new
252 name.
253 */
254 "name": "bitflags",
255 /* The Package ID of the dependency. */
256 "pkg": "bitflags 1.0.4 (registry+https://github.com/rust\-lang/crates.io\-index)",
257 /* Array of dependency kinds. Added in Cargo 1.40. */
258 "dep_kinds": [
259 {
260 /* The dependency kind.
261 "dev", "build", or null for a normal dependency.
262 */
263 "kind": null,
264 /* The target platform for the dependency.
265 null if not a target dependency.
266 */
267 "target": "cfg(windows)"
268 }
269 ]
270 }
271 ],
272 /* Array of features enabled on this package. */
273 "features": [
274 "default"
275 ]
276 }
277 ],
278 /* The root package of the workspace.
279 This is null if this is a virtual workspace. Otherwise it is
280 the Package ID of the root package.
281 */
282 "root": "my\-package 0.1.0 (path+file:///path/to/my\-package)"
283 },
284 /* The absolute path to the build directory where Cargo places its output. */
285 "target_directory": "/path/to/my\-package/target",
286 /* The version of the schema for this metadata structure.
287 This will be changed if incompatible changes are ever made.
288 */
289 "version": 1,
290 /* The absolute path to the root of the workspace. */
291 "workspace_root": "/path/to/my\-package"
292 /* Workspace metadata.
293 This is null if no metadata is specified. */
294 "metadata": {
295 "docs": {
296 "rs": {
297 "all\-features": true
298 }
299 }
300 }
301}
302.fi
303.if n .RE
304.SH "OPTIONS"
305.SS "Output Options"
306.sp
307\fB\-\-no\-deps\fP
308.RS 4
309Output information only about the workspace members and don\(cqt fetch
310dependencies.
311.RE
312.sp
313\fB\-\-format\-version\fP \fIVERSION\fP
314.RS 4
315Specify the version of the output format to use. Currently \fB1\fP is the only
316possible value.
317.RE
318.sp
319\fB\-\-filter\-platform\fP \fITRIPLE\fP
320.RS 4
321This filters the \fBresolve\fP output to only include dependencies for the
322given target triple. Without this flag, the resolve includes all targets.
323.sp
324Note that the dependencies listed in the "packages" array still includes all
325dependencies. Each package definition is intended to be an unaltered
326reproduction of the information within \fBCargo.toml\fP.
327.RE
328.SS "Feature Selection"
329.sp
330The feature flags allow you to control the enabled features for the "current"
331package. The "current" package is the package in the current directory, or the
332one specified in \fB\-\-manifest\-path\fP. If running in the root of a virtual
333workspace, then the default features are selected for all workspace members,
334or all features if \fB\-\-all\-features\fP is specified.
335.sp
336When no feature options are given, the \fBdefault\fP feature is activated for
337every selected package.
338.sp
339\fB\-\-features\fP \fIFEATURES\fP
340.RS 4
341Space or comma separated list of features to activate. These features only
342apply to the current directory\(cqs package. Features of direct dependencies
343may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax. This flag may be
344specified multiple times, which enables all specified features.
345.RE
346.sp
347\fB\-\-all\-features\fP
348.RS 4
349Activate all available features of all selected packages.
350.RE
351.sp
352\fB\-\-no\-default\-features\fP
353.RS 4
354Do not activate the \fBdefault\fP feature of the current directory\(cqs
355package.
356.RE
357.SS "Display Options"
358.sp
359\fB\-v\fP, \fB\-\-verbose\fP
360.RS 4
361Use verbose output. May be specified twice for "very verbose" output which
362includes extra output such as dependency warnings and build script output.
363May also be specified with the \fBterm.verbose\fP
364.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
365.RE
366.sp
367\fB\-q\fP, \fB\-\-quiet\fP
368.RS 4
369No output printed to stdout.
370.RE
371.sp
372\fB\-\-color\fP \fIWHEN\fP
373.RS 4
374Control when colored output is used. Valid values:
375.sp
376.RS 4
377.ie n \{\
378\h'-04'\(bu\h'+03'\c
379.\}
380.el \{\
381. sp -1
382. IP \(bu 2.3
383.\}
384\fBauto\fP (default): Automatically detect if color support is available on the
385terminal.
386.RE
387.sp
388.RS 4
389.ie n \{\
390\h'-04'\(bu\h'+03'\c
391.\}
392.el \{\
393. sp -1
394. IP \(bu 2.3
395.\}
396\fBalways\fP: Always display colors.
397.RE
398.sp
399.RS 4
400.ie n \{\
401\h'-04'\(bu\h'+03'\c
402.\}
403.el \{\
404. sp -1
405. IP \(bu 2.3
406.\}
407\fBnever\fP: Never display colors.
408.RE
409.sp
410May also be specified with the \fBterm.color\fP
411.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
412.RE
413.SS "Manifest Options"
414.sp
415\fB\-\-manifest\-path\fP \fIPATH\fP
416.RS 4
417Path to the \fBCargo.toml\fP file. By default, Cargo searches for the
418\fBCargo.toml\fP file in the current directory or any parent directory.
419.RE
420.sp
421\fB\-\-frozen\fP, \fB\-\-locked\fP
422.RS 4
423Either of these flags requires that the \fBCargo.lock\fP file is
424up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will
425exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from
426attempting to access the network to determine if it is out\-of\-date.
427.sp
428These may be used in environments where you want to assert that the
429\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
430access.
431.RE
432.sp
433\fB\-\-offline\fP
434.RS 4
435Prevents Cargo from accessing the network for any reason. Without this
436flag, Cargo will stop with an error if it needs to access the network and
437the network is not available. With this flag, Cargo will attempt to
438proceed without the network if possible.
439.sp
440Beware that this may result in different dependency resolution than online
441mode. Cargo will restrict itself to crates that are downloaded locally, even
442if there might be a newer version as indicated in the local copy of the index.
443See the \fBcargo\-fetch\fP(1) command to download dependencies before going
444offline.
445.sp
446May also be specified with the \fBnet.offline\fP \c
447.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
448.RE
449.SS "Common Options"
450.sp
451\fB+TOOLCHAIN\fP
452.RS 4
453If Cargo has been installed with rustup, and the first argument to \fBcargo\fP
454begins with \fB+\fP, it will be interpreted as a rustup toolchain name (such
455as \fB+stable\fP or \fB+nightly\fP).
456See the \c
457.URL "https://github.com/rust\-lang/rustup/" "rustup documentation"
458for more information about how toolchain overrides work.
459.RE
460.sp
461\fB\-h\fP, \fB\-\-help\fP
462.RS 4
463Prints help information.
464.RE
465.sp
466\fB\-Z\fP \fIFLAG\fP...
467.RS 4
468Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for
469details.
470.RE
471.SH "ENVIRONMENT"
472.sp
473See \c
474.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " "
475for
476details on environment variables that Cargo reads.
477.SH "EXIT STATUS"
478.sp
4790
480.RS 4
481Cargo succeeded.
482.RE
483.sp
484101
485.RS 4
486Cargo failed to complete.
487.RE
488.SH "EXAMPLES"
489.sp
490.RS 4
491.ie n \{\
492\h'-04' 1.\h'+01'\c
493.\}
494.el \{\
495. sp -1
496. IP " 1." 4.2
497.\}
498Output JSON about the current package:
499.sp
500.if n .RS 4
501.nf
502cargo metadata \-\-format\-version=1
503.fi
504.if n .RE
505.RE
506.SH "SEE ALSO"
507.sp
508\fBcargo\fP(1)