blob: 95a46d79c7072687245de26cea8364ebb8caa135 [file] [log] [blame]
Matthew Maurerbd398542019-09-05 16:25:08 -07001'\" t
2.\" Title: cargo-metadata
3.\" Author: [see the "AUTHOR(S)" section]
4.\" Generator: Asciidoctor 1.5.8
5.\" Date: 2019-05-08
6.\" Manual: \ \&
7.\" Source: \ \&
8.\" Language: English
9.\"
10.TH "CARGO\-METADATA" "1" "2019-05-08" "\ \&" "\ \&"
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 the resolved dependencies of a package, the concrete used versions
38including overrides, in JSON to stdout.
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 }
156 ],
157 /* Set of features defined for the package.
158 Each feature maps to an array of features or dependencies it
159 enables.
160 */
161 "features": {
162 "default": [
163 "feat1"
164 ],
165 "feat1": [],
166 "feat2": []
167 },
168 /* Absolute path to this package\(aqs manifest. */
169 "manifest_path": "/path/to/my\-package/Cargo.toml",
170 /* Package metadata.
171 This is null if no metadata is specified.
172 */
173 "metadata": {
174 "docs": {
175 "rs": {
176 "all\-features": true
177 }
178 }
179 },
180 /* Array of authors from the manifest.
181 Empty array if no authors specified.
182 */
183 "authors": [
184 "Jane Doe <user@example.com>"
185 ],
186 /* Array of categories from the manifest. */
187 "categories": [
188 "command\-line\-utilities"
189 ],
190 /* Array of keywords from the manifest. */
191 "keywords": [
192 "cli"
193 ],
194 /* The readme value from the manifest or null if not specified. */
195 "readme": "README.md",
196 /* The repository value from the manifest or null if not specified. */
197 "repository": "https://github.com/rust\-lang/cargo",
198 /* The default edition of the package.
199 Note that individual targets may have different editions.
200 */
201 "edition": "2018",
202 /* Optional string that is the name of a native library the package
203 is linking to.
204 */
205 "links": null,
206 }
207 ],
208 /* Array of members of the workspace.
209 Each entry is the Package ID for the package.
210 */
211 "workspace_members": [
212 "my\-package 0.1.0 (path+file:///path/to/my\-package)",
213 ],
214 /* The resolved dependency graph, with the concrete versions and features
215 selected. The set depends on the enabled features.
216 This is null if \-\-no\-deps is specified.
217 */
218 "resolve": {
219 /* Array of nodes within the dependency graph.
220 Each node is a package.
221 */
222 "nodes": [
223 {
224 /* The Package ID of this node. */
225 "id": "my\-package 0.1.0 (path+file:///path/to/my\-package)",
226 /* The dependencies of this package, an array of Package IDs. */
227 "dependencies": [
228 "bitflags 1.0.4 (registry+https://github.com/rust\-lang/crates.io\-index)"
229 ],
230 /* The dependencies of this package. This is an alternative to
231 "dependencies" which contains additional information. In
232 particular, this handles renamed dependencies.
233 */
234 "deps": [
235 {
236 /* The name of the dependency\(aqs library target.
237 If this is a renamed dependency, this is the new
238 name.
239 */
240 "name": "bitflags",
241 /* The Package ID of the dependency. */
242 "pkg": "bitflags 1.0.4 (registry+https://github.com/rust\-lang/crates.io\-index)"
243 }
244 ],
245 /* Array of features enabled on this package. */
246 "features": [
247 "default"
248 ]
249 }
250 ],
251 /* The root package of the workspace.
252 This is null if this is a virtual workspace. Otherwise it is
253 the Package ID of the root package.
254 */
255 "root": "my\-package 0.1.0 (path+file:///path/to/my\-package)"
256 },
257 /* The absolute path to the build directory where Cargo places its output. */
258 "target_directory": "/path/to/my\-package/target",
259 /* The version of the schema for this metadata structure.
260 This will be changed if incompatible changes are ever made.
261 */
262 "version": 1,
263 /* The absolute path to the root of the workspace. */
264 "workspace_root": "/path/to/my\-package"
265}
266.fi
267.if n .RE
268.SH "OPTIONS"
269.SS "Output Options"
270.sp
271\fB\-\-no\-deps\fP
272.RS 4
273Output information only about the workspace members and don\(cqt fetch
274dependencies.
275.RE
276.sp
277\fB\-\-format\-version\fP \fIVERSION\fP
278.RS 4
279Specify the version of the output format to use. Currently \fB1\fP is the only
280possible value.
281.RE
282.SS "Feature Selection"
283.sp
284When no feature options are given, the \fBdefault\fP feature is activated for
285every selected package.
286.sp
287\fB\-\-features\fP \fIFEATURES\fP
288.RS 4
289Space or comma separated list of features to activate. These features only
290apply to the current directory\(cqs package. Features of direct dependencies
291may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax.
292.RE
293.sp
294\fB\-\-all\-features\fP
295.RS 4
296Activate all available features of all selected packages.
297.RE
298.sp
299\fB\-\-no\-default\-features\fP
300.RS 4
301Do not activate the \fBdefault\fP feature of the current directory\(cqs
302package.
303.RE
304.SS "Display Options"
305.sp
306\fB\-v\fP, \fB\-\-verbose\fP
307.RS 4
308Use verbose output. May be specified twice for "very verbose" output which
309includes extra output such as dependency warnings and build script output.
310May also be specified with the \fBterm.verbose\fP
311.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
312.RE
313.sp
314\fB\-q\fP, \fB\-\-quiet\fP
315.RS 4
316No output printed to stdout.
317.RE
318.sp
319\fB\-\-color\fP \fIWHEN\fP
320.RS 4
321Control when colored output is used. Valid values:
322.sp
323.RS 4
324.ie n \{\
325\h'-04'\(bu\h'+03'\c
326.\}
327.el \{\
328. sp -1
329. IP \(bu 2.3
330.\}
331\fBauto\fP (default): Automatically detect if color support is available on the
332terminal.
333.RE
334.sp
335.RS 4
336.ie n \{\
337\h'-04'\(bu\h'+03'\c
338.\}
339.el \{\
340. sp -1
341. IP \(bu 2.3
342.\}
343\fBalways\fP: Always display colors.
344.RE
345.sp
346.RS 4
347.ie n \{\
348\h'-04'\(bu\h'+03'\c
349.\}
350.el \{\
351. sp -1
352. IP \(bu 2.3
353.\}
354\fBnever\fP: Never display colors.
355.RE
356.sp
357May also be specified with the \fBterm.color\fP
358.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
359.RE
360.SS "Manifest Options"
361.sp
362\fB\-\-manifest\-path\fP \fIPATH\fP
363.RS 4
364Path to the \fBCargo.toml\fP file. By default, Cargo searches in the current
365directory or any parent directory for the \fBCargo.toml\fP file.
366.RE
367.sp
368\fB\-\-frozen\fP, \fB\-\-locked\fP
369.RS 4
370Either of these flags requires that the \fBCargo.lock\fP file is
371up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will
372exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from
373attempting to access the network to determine if it is out\-of\-date.
374.sp
375These may be used in environments where you want to assert that the
376\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
377access.
378.RE
379.sp
380\fB\-\-offline\fP
381.RS 4
382Prevents Cargo from accessing the network for any reason. Without this
383flag, Cargo will stop with an error if it needs to access the network and
384the network is not available. With this flag, Cargo will attempt to
385proceed without the network if possible.
386.sp
387Beware that this may result in different dependency resolution than online
388mode. Cargo will restrict itself to crates that are downloaded locally, even
389if there might be a newer version as indicated in the local copy of the index.
390See the \fBcargo\-fetch\fP(1) command to download dependencies before going
391offline.
392.sp
393May also be specified with the \fBnet.offline\fP \c
394.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
395.RE
396.SS "Common Options"
397.sp
398\fB\-h\fP, \fB\-\-help\fP
399.RS 4
400Prints help information.
401.RE
402.sp
403\fB\-Z\fP \fIFLAG\fP...
404.RS 4
405Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for
406details.
407.RE
408.SH "ENVIRONMENT"
409.sp
410See \c
411.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " "
412for
413details on environment variables that Cargo reads.
414.SH "EXIT STATUS"
415.sp
4160
417.RS 4
418Cargo succeeded.
419.RE
420.sp
421101
422.RS 4
423Cargo failed to complete.
424.RE
425.SH "EXAMPLES"
426.sp
427.RS 4
428.ie n \{\
429\h'-04' 1.\h'+01'\c
430.\}
431.el \{\
432. sp -1
433. IP " 1." 4.2
434.\}
435Output JSON about the current package:
436.sp
437.if n .RS 4
438.nf
439cargo metadata \-\-format\-version=1
440.fi
441.if n .RE
442.RE
443.SH "SEE ALSO"
444.sp
445\fBcargo\fP(1)