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                           }
128                       ],
129                       /* Set of features defined for the package.
130                          Each feature maps to an array of features or dependencies it
131                          enables.
132                       */
133                       "features": {
134                           "default": [
135                               "feat1"
136                           ],
137                           "feat1": [],
138                           "feat2": []
139                       },
140                       /* Absolute path to this package's manifest. */
141                       "manifest_path": "/path/to/my-package/Cargo.toml",
142                       /* Package metadata.
143                          This is null if no metadata is specified.
144                       */
145                       "metadata": {
146                           "docs": {
147                               "rs": {
148                                   "all-features": true
149                               }
150                           }
151                       },
152                       /* Array of authors from the manifest.
153                          Empty array if no authors specified.
154                       */
155                       "authors": [
156                           "Jane Doe <user@example.com>"
157                       ],
158                       /* Array of categories from the manifest. */
159                       "categories": [
160                           "command-line-utilities"
161                       ],
162                       /* Array of keywords from the manifest. */
163                       "keywords": [
164                           "cli"
165                       ],
166                       /* The readme value from the manifest or null if not specified. */
167                       "readme": "README.md",
168                       /* The repository value from the manifest or null if not specified. */
169                       "repository": "https://github.com/rust-lang/cargo",
170                       /* The default edition of the package.
171                          Note that individual targets may have different editions.
172                       */
173                       "edition": "2018",
174                       /* Optional string that is the name of a native library the package
175                          is linking to.
176                       */
177                       "links": null,
178                   }
179               ],
180               /* Array of members of the workspace.
181                  Each entry is the Package ID for the package.
182               */
183               "workspace_members": [
184                   "my-package 0.1.0 (path+file:///path/to/my-package)",
185               ],
186               /* The resolved dependency graph, with the concrete versions and features
187                  selected. The set depends on the enabled features.
188                  This is null if --no-deps is specified.
189               */
190               "resolve": {
191                   /* Array of nodes within the dependency graph.
192                      Each node is a package.
193                   */
194                   "nodes": [
195                       {
196                           /* The Package ID of this node. */
197                           "id": "my-package 0.1.0 (path+file:///path/to/my-package)",
198                           /* The dependencies of this package, an array of Package IDs. */
199                           "dependencies": [
200                               "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)"
201                           ],
202                           /* The dependencies of this package. This is an alternative to
203                              "dependencies" which contains additional information. In
204                              particular, this handles renamed dependencies.
205                           */
206                           "deps": [
207                               {
208                                   /* The name of the dependency's library target.
209                                      If this is a renamed dependency, this is the new
210                                      name.
211                                   */
212                                   "name": "bitflags",
213                                   /* The Package ID of the dependency. */
214                                   "pkg": "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)"
215                               }
216                           ],
217                           /* Array of features enabled on this package. */
218                           "features": [
219                               "default"
220                           ]
221                       }
222                   ],
223                   /* The root package of the workspace.
224                      This is null if this is a virtual workspace. Otherwise it is
225                      the Package ID of the root package.
226                   */
227                   "root": "my-package 0.1.0 (path+file:///path/to/my-package)"
228               },
229               /* The absolute path to the build directory where Cargo places its output. */
230               "target_directory": "/path/to/my-package/target",
231               /* The version of the schema for this metadata structure.
232                  This will be changed if incompatible changes are ever made.
233               */
234               "version": 1,
235               /* The absolute path to the root of the workspace. */
236               "workspace_root": "/path/to/my-package"
237           }
238

OPTIONS

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

ENVIRONMENT

315       See the reference
316       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
317       for details on environment variables that Cargo reads.
318

EXIT STATUS

320       0
321           Cargo succeeded.
322
323       101
324           Cargo failed to complete.
325

EXAMPLES

327        1. Output JSON about the current package:
328
329               cargo metadata --format-version=1
330

SEE ALSO

332       cargo(1)
333
334
335
336                                  2019-01-05                 CARGO-METADATA(1)
Impressum