1CARGO-METADATA(1)                                            CARGO-METADATA(1)
2
3
4

NAME

6       cargo-metadata - Machine-readable metadata about the current package
7

SYNOPSIS

9       cargo metadata [OPTIONS]
10

DESCRIPTION

12       Output the resolved dependencies of a package, the concrete used
13       versions including overrides, in JSON to stdout.
14
15       It is recommended to include the --format-version flag to future-proof
16       your code to ensure the output is in the format you are expecting.
17
18       See the cargo_metadata crate <https://crates.io/crates/cargo_metadata>
19       for a Rust API for reading the metadata.
20

OUTPUT FORMAT

22       The output has the following format:
23
24           {
25               /* Array of all packages in the workspace.
26                  It also includes all feature-enabled dependencies unless --no-deps is used.
27               */
28               "packages": [
29                   {
30                       /* The name of the package. */
31                       "name": "my-package",
32                       /* The version of the package. */
33                       "version": "0.1.0",
34                       /* The Package ID, a unique identifier for referring to the package. */
35                       "id": "my-package 0.1.0 (path+file:///path/to/my-package)",
36                       /* The license value from the manifest, or null. */
37                       "license": "MIT/Apache-2.0",
38                       /* The license-file value from the manifest, or null. */
39                       "license_file": "LICENSE",
40                       /* The description value from the manifest, or null. */
41                       "description": "Package description.",
42                       /* The source ID of the package. This represents where
43                          a package is retrieved from.
44                          This is null for path dependencies and workspace members.
45                          For other dependencies, it is a string with the format:
46                          - "registry+URL" for registry-based dependencies.
47                            Example: "registry+https://github.com/rust-lang/crates.io-index"
48                          - "git+URL" for git-based dependencies.
49                            Example: "git+https://github.com/rust-lang/cargo?rev=5e85ba14aaa20f8133863373404cb0af69eeef2c#5e85ba14aaa20f8133863373404cb0af69eeef2c"
50                       */
51                       "source": null,
52                       /* Array of dependencies declared in the package's manifest. */
53                       "dependencies": [
54                           {
55                               /* The name of the dependency. */
56                               "name": "bitflags",
57                               /* The source ID of the dependency. May be null, see
58                                  description for the package source.
59                               */
60                               "source": "registry+https://github.com/rust-lang/crates.io-index",
61                               /* The version requirement for the dependency.
62                                  Dependencies without a version requirement have a value of "*".
63                               */
64                               "req": "^1.0",
65                               /* The dependency kind.
66                                  "dev", "build", or null for a normal dependency.
67                               */
68                               "kind": null,
69                               /* If the dependency is renamed, this is the new name for
70                                  the dependency as a string. null if it is not renamed.
71                               */
72                               "rename": null,
73                               /* Boolean of whether or not this is an optional dependency. */
74                               "optional": false,
75                               /* Boolean of whether or not default features are enabled. */
76                               "uses_default_features": true,
77                               /* Array of features enabled. */
78                               "features": [],
79                               /* The target platform for the dependency.
80                                  null if not a target dependency.
81                               */
82                               "target": "cfg(windows)",
83                               /* A string of the URL of the registry this dependency is from.
84                                  If not specified or null, the dependency is from the default
85                                  registry (crates.io).
86                               */
87                               "registry": null
88                           }
89                       ],
90                       /* Array of Cargo targets. */
91                       "targets": [
92                           {
93                               /* Array of target kinds.
94                                  - lib targets list the `crate-type` values from the
95                                    manifest such as "lib", "rlib", "dylib",
96                                    "proc-macro", etc. (default ["lib"])
97                                  - binary is ["bin"]
98                                  - example is ["example"]
99                                  - integration test is ["test"]
100                                  - benchmark is ["bench"]
101                                  - build script is ["custom-build"]
102                               */
103                               "kind": [
104                                   "bin"
105                               ],
106                               /* Array of crate types.
107                                  - lib and example libraries list the `crate-type` values
108                                    from the manifest such as "lib", "rlib", "dylib",
109                                    "proc-macro", etc. (default ["lib"])
110                                  - all other target kinds are ["bin"]
111                               */
112                               "crate_types": [
113                                   "bin"
114                               ],
115                               /* The name of the target. */
116                               "name": "my-package",
117                               /* Absolute path to the root source file of the target. */
118                               "src_path": "/path/to/my-package/src/main.rs",
119                               /* The Rust edition of the target.
120                                  Defaults to the package edition.
121                               */
122                               "edition": "2018",
123                               /* Array of required features.
124                                  This property is not included if no required features are set.
125                               */
126                               "required-features": ["feat1"],
127                               /* Whether or not this target has doc tests enabled, and
128                                  the target is compatible with doc testing.
129                               */
130                               "doctest": false
131                           }
132                       ],
133                       /* Set of features defined for the package.
134                          Each feature maps to an array of features or dependencies it
135                          enables.
136                       */
137                       "features": {
138                           "default": [
139                               "feat1"
140                           ],
141                           "feat1": [],
142                           "feat2": []
143                       },
144                       /* Absolute path to this package's manifest. */
145                       "manifest_path": "/path/to/my-package/Cargo.toml",
146                       /* Package metadata.
147                          This is null if no metadata is specified.
148                       */
149                       "metadata": {
150                           "docs": {
151                               "rs": {
152                                   "all-features": true
153                               }
154                           }
155                       },
156                       /* Array of authors from the manifest.
157                          Empty array if no authors specified.
158                       */
159                       "authors": [
160                           "Jane Doe <user@example.com>"
161                       ],
162                       /* Array of categories from the manifest. */
163                       "categories": [
164                           "command-line-utilities"
165                       ],
166                       /* Array of keywords from the manifest. */
167                       "keywords": [
168                           "cli"
169                       ],
170                       /* The readme value from the manifest or null if not specified. */
171                       "readme": "README.md",
172                       /* The repository value from the manifest or null if not specified. */
173                       "repository": "https://github.com/rust-lang/cargo",
174                       /* The default edition of the package.
175                          Note that individual targets may have different editions.
176                       */
177                       "edition": "2018",
178                       /* Optional string that is the name of a native library the package
179                          is linking to.
180                       */
181                       "links": null,
182                   }
183               ],
184               /* Array of members of the workspace.
185                  Each entry is the Package ID for the package.
186               */
187               "workspace_members": [
188                   "my-package 0.1.0 (path+file:///path/to/my-package)",
189               ],
190               /* The resolved dependency graph, with the concrete versions and features
191                  selected. The set depends on the enabled features.
192                  This is null if --no-deps is specified.
193               */
194               "resolve": {
195                   /* Array of nodes within the dependency graph.
196                      Each node is a package.
197                   */
198                   "nodes": [
199                       {
200                           /* The Package ID of this node. */
201                           "id": "my-package 0.1.0 (path+file:///path/to/my-package)",
202                           /* The dependencies of this package, an array of Package IDs. */
203                           "dependencies": [
204                               "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)"
205                           ],
206                           /* The dependencies of this package. This is an alternative to
207                              "dependencies" which contains additional information. In
208                              particular, this handles renamed dependencies.
209                           */
210                           "deps": [
211                               {
212                                   /* The name of the dependency's library target.
213                                      If this is a renamed dependency, this is the new
214                                      name.
215                                   */
216                                   "name": "bitflags",
217                                   /* The Package ID of the dependency. */
218                                   "pkg": "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)"
219                               }
220                           ],
221                           /* Array of features enabled on this package. */
222                           "features": [
223                               "default"
224                           ]
225                       }
226                   ],
227                   /* The root package of the workspace.
228                      This is null if this is a virtual workspace. Otherwise it is
229                      the Package ID of the root package.
230                   */
231                   "root": "my-package 0.1.0 (path+file:///path/to/my-package)"
232               },
233               /* The absolute path to the build directory where Cargo places its output. */
234               "target_directory": "/path/to/my-package/target",
235               /* The version of the schema for this metadata structure.
236                  This will be changed if incompatible changes are ever made.
237               */
238               "version": 1,
239               /* The absolute path to the root of the workspace. */
240               "workspace_root": "/path/to/my-package"
241           }
242

OPTIONS

244   Output Options
245       --no-deps
246           Output information only about the workspace members and don’t fetch
247           dependencies.
248
249       --format-version VERSION
250           Specify the version of the output format to use. Currently 1 is the
251           only possible value.
252
253   Feature Selection
254       When no feature options are given, the default feature is activated for
255       every selected package.
256
257       --features FEATURES
258           Space or comma separated list of features to activate. These
259           features only apply to the current directory’s package. Features of
260           direct dependencies may be enabled with <dep-name>/<feature-name>
261           syntax.
262
263       --all-features
264           Activate all available features of all selected packages.
265
266       --no-default-features
267           Do not activate the default feature of the current directory’s
268           package.
269
270   Display Options
271       -v, --verbose
272           Use verbose output. May be specified twice for "very verbose"
273           output which includes extra output such as dependency warnings and
274           build script output. May also be specified with the term.verbose
275           config value
276           <https://doc.rust-lang.org/cargo/reference/config.html>.
277
278       -q, --quiet
279           No output printed to stdout.
280
281       --color WHEN
282           Control when colored output is used. Valid values:
283
284           ·   auto (default): Automatically detect if color support is
285               available on the terminal.
286
287           ·   always: Always display colors.
288
289           ·   never: Never display colors.
290
291           May also be specified with the term.color config value
292           <https://doc.rust-lang.org/cargo/reference/config.html>.
293
294   Manifest Options
295       --manifest-path PATH
296           Path to the Cargo.toml file. By default, Cargo searches in the
297           current directory or any parent directory for the Cargo.toml file.
298
299       --frozen, --locked
300           Either of these flags requires that the Cargo.lock file is
301           up-to-date. If the lock file is missing, or it needs to be updated,
302           Cargo will exit with an error. The --frozen flag also prevents
303           Cargo from attempting to access the network to determine if it is
304           out-of-date.
305
306           These may be used in environments where you want to assert that the
307           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
308           network access.
309
310       --offline
311           Prevents Cargo from accessing the network for any reason. Without
312           this flag, Cargo will stop with an error if it needs to access the
313           network and the network is not available. With this flag, Cargo
314           will attempt to proceed without the network if possible.
315
316           Beware that this may result in different dependency resolution than
317           online mode. Cargo will restrict itself to crates that are
318           downloaded locally, even if there might be a newer version as
319           indicated in the local copy of the index. See the cargo-fetch(1)
320           command to download dependencies before going offline.
321
322           May also be specified with the net.offline config value
323           <https://doc.rust-lang.org/cargo/reference/config.html>.
324
325   Common Options
326       -h, --help
327           Prints help information.
328
329       -Z FLAG...
330           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
331           details.
332

ENVIRONMENT

334       See the reference
335       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
336       for details on environment variables that Cargo reads.
337

EXIT STATUS

339       0
340           Cargo succeeded.
341
342       101
343           Cargo failed to complete.
344

EXAMPLES

346        1. Output JSON about the current package:
347
348               cargo metadata --format-version=1
349

SEE ALSO

351       cargo(1)
352
353
354
355                                  2019-06-07                 CARGO-METADATA(1)
Impressum