fork/cargo
git clone https://git.julia.blue/fork/cargo
26f5f3f50
0.87.0
1CARGO-METADATA(1) 2 3NAME 4 cargo-metadata — Machine-readable metadata about the current package 5 6SYNOPSIS 7 cargo metadata [options] 8 9DESCRIPTION 10 Output JSON to stdout containing information about the workspace members 11 and resolved dependencies of the current package. 12 13 The output format is subject to change in future versions of Cargo. It 14 is recommended to include the --format-version flag to future-proof your 15 code and ensure the output is in the format you are expecting. For more 16 on the expectations, see “Compatibility”. 17 18 See the cargo_metadata crate <https://crates.io/crates/cargo_metadata> 19 for a Rust API for reading the metadata. 20 21OUTPUT FORMAT 22 Compatibility 23 Within the same output format version, the compatibility is maintained, 24 except some scenarios. The following is a non-exhaustive list of changes 25 that are not considered as incompatible: 26 27 o Adding new fields — New fields will be added when needed. Reserving 28 this helps Cargo evolve without bumping the format version too often. 29 30 o Adding new values for enum-like fields — Same as adding new fields. 31 It keeps metadata evolving without stagnation. 32 33 o Changing opaque representations — The inner representations of some 34 fields are implementation details. For example, fields related to 35 “Source ID” are treated as opaque identifiers to differentiate 36 packages or sources. Consumers shouldn’t rely on those 37 representations unless specified. 38 39 JSON format 40 The JSON output has the following format: 41 42 { 43 /* Array of all packages in the workspace. 44 It also includes all feature-enabled dependencies unless --no-deps is used. 45 */ 46 "packages": [ 47 { 48 /* The name of the package. */ 49 "name": "my-package", 50 /* The version of the package. */ 51 "version": "0.1.0", 52 /* The Package ID for referring to the 53 package within the document and as the `--package` argument to many commands 54 */ 55 "id": "file:///path/to/my-package#0.1.0", 56 /* The license value from the manifest, or null. */ 57 "license": "MIT/Apache-2.0", 58 /* The license-file value from the manifest, or null. */ 59 "license_file": "LICENSE", 60 /* The description value from the manifest, or null. */ 61 "description": "Package description.", 62 /* The source ID of the package, an "opaque" identifier representing 63 where a package is retrieved from. See "Compatibility" above for 64 the stability guarantee. 65 66 This is null for path dependencies and workspace members. 67 68 For other dependencies, it is a string with the format: 69 - "registry+URL" for registry-based dependencies. 70 Example: "registry+https://github.com/rust-lang/crates.io-index" 71 - "git+URL" for git-based dependencies. 72 Example: "git+https://github.com/rust-lang/cargo?rev=5e85ba14aaa20f8133863373404cb0af69eeef2c#5e85ba14aaa20f8133863373404cb0af69eeef2c" 73 - "sparse+URL" for dependencies from a sparse registry 74 Example: "sparse+https://my-sparse-registry.org" 75 76 The value after the `+` is not explicitly defined, and may change 77 between versions of Cargo and may not directly correlate to other 78 things, such as registry definitions in a config file. New source 79 kinds may be added in the future which will have different `+` 80 prefixed identifiers. 81 */ 82 "source": null, 83 /* Array of dependencies declared in the package's manifest. */ 84 "dependencies": [ 85 { 86 /* The name of the dependency. */ 87 "name": "bitflags", 88 /* The source ID of the dependency. May be null, see 89 description for the package source. 90 */ 91 "source": "registry+https://github.com/rust-lang/crates.io-index", 92 /* The version requirement for the dependency. 93 Dependencies without a version requirement have a value of "*". 94 */ 95 "req": "^1.0", 96 /* The dependency kind. 97 "dev", "build", or null for a normal dependency. 98 */ 99 "kind": null, 100 /* If the dependency is renamed, this is the new name for 101 the dependency as a string. null if it is not renamed. 102 */ 103 "rename": null, 104 /* Boolean of whether or not this is an optional dependency. */ 105 "optional": false, 106 /* Boolean of whether or not default features are enabled. */ 107 "uses_default_features": true, 108 /* Array of features enabled. */ 109 "features": [], 110 /* The target platform for the dependency. 111 null if not a target dependency. 112 */ 113 "target": "cfg(windows)", 114 /* The file system path for a local path dependency. 115 not present if not a path dependency. 116 */ 117 "path": "/path/to/dep", 118 /* A string of the URL of the registry this dependency is from. 119 If not specified or null, the dependency is from the default 120 registry (crates.io). 121 */ 122 "registry": null, 123 /* (unstable) Boolean flag of whether or not this is a pulbic 124 dependency. This field is only present when 125 `-Zpublic-dependency` is enabled. 126 */ 127 "public": false 128 } 129 ], 130 /* Array of Cargo targets. */ 131 "targets": [ 132 { 133 /* Array of target kinds. 134 - lib targets list the `crate-type` values from the 135 manifest such as "lib", "rlib", "dylib", 136 "proc-macro", etc. (default ["lib"]) 137 - binary is ["bin"] 138 - example is ["example"] 139 - integration test is ["test"] 140 - benchmark is ["bench"] 141 - build script is ["custom-build"] 142 */ 143 "kind": [ 144 "bin" 145 ], 146 /* Array of crate types. 147 - lib and example libraries list the `crate-type` values 148 from the manifest such as "lib", "rlib", "dylib", 149 "proc-macro", etc. (default ["lib"]) 150 - all other target kinds are ["bin"] 151 */ 152 "crate_types": [ 153 "bin" 154 ], 155 /* The name of the target. 156 For lib targets, dashes will be replaced with underscores. 157 */ 158 "name": "my-package", 159 /* Absolute path to the root source file of the target. */ 160 "src_path": "/path/to/my-package/src/main.rs", 161 /* The Rust edition of the target. 162 Defaults to the package edition. 163 */ 164 "edition": "2018", 165 /* Array of required features. 166 This property is not included if no required features are set. 167 */ 168 "required-features": ["feat1"], 169 /* Whether the target should be documented by `cargo doc`. */ 170 "doc": true, 171 /* Whether or not this target has doc tests enabled, and 172 the target is compatible with doc testing. 173 */ 174 "doctest": false, 175 /* Whether or not this target should be built and run with `--test` 176 */ 177 "test": true 178 } 179 ], 180 /* Set of features defined for the package. 181 Each feature maps to an array of features or dependencies it 182 enables. 183 */ 184 "features": { 185 "default": [ 186 "feat1" 187 ], 188 "feat1": [], 189 "feat2": [] 190 }, 191 /* Absolute path to this package's manifest. */ 192 "manifest_path": "/path/to/my-package/Cargo.toml", 193 /* Package metadata. 194 This is null if no metadata is specified. 195 */ 196 "metadata": { 197 "docs": { 198 "rs": { 199 "all-features": true 200 } 201 } 202 }, 203 /* List of registries to which this package may be published. 204 Publishing is unrestricted if null, and forbidden if an empty array. */ 205 "publish": [ 206 "crates-io" 207 ], 208 /* Array of authors from the manifest. 209 Empty array if no authors specified. 210 */ 211 "authors": [ 212 "Jane Doe <user@example.com>" 213 ], 214 /* Array of categories from the manifest. */ 215 "categories": [ 216 "command-line-utilities" 217 ], 218 /* Optional string that is the default binary picked by cargo run. */ 219 "default_run": null, 220 /* Optional string that is the minimum supported rust version */ 221 "rust_version": "1.56", 222 /* Array of keywords from the manifest. */ 223 "keywords": [ 224 "cli" 225 ], 226 /* The readme value from the manifest or null if not specified. */ 227 "readme": "README.md", 228 /* The repository value from the manifest or null if not specified. */ 229 "repository": "https://github.com/rust-lang/cargo", 230 /* The homepage value from the manifest or null if not specified. */ 231 "homepage": "https://rust-lang.org", 232 /* The documentation value from the manifest or null if not specified. */ 233 "documentation": "https://doc.rust-lang.org/stable/std", 234 /* The default edition of the package. 235 Note that individual targets may have different editions. 236 */ 237 "edition": "2018", 238 /* Optional string that is the name of a native library the package 239 is linking to. 240 */ 241 "links": null, 242 } 243 ], 244 /* Array of members of the workspace. 245 Each entry is the Package ID for the package. 246 */ 247 "workspace_members": [ 248 "file:///path/to/my-package#0.1.0", 249 ], 250 /* Array of default members of the workspace. 251 Each entry is the Package ID for the package. 252 */ 253 "workspace_default_members": [ 254 "file:///path/to/my-package#0.1.0", 255 ], 256 // The resolved dependency graph for the entire workspace. The enabled 257 // features are based on the enabled features for the "current" package. 258 // Inactivated optional dependencies are not listed. 259 // 260 // This is null if --no-deps is specified. 261 // 262 // By default, this includes all dependencies for all target platforms. 263 // The `--filter-platform` flag may be used to narrow to a specific 264 // target triple. 265 "resolve": { 266 /* Array of nodes within the dependency graph. 267 Each node is a package. 268 */ 269 "nodes": [ 270 { 271 /* The Package ID of this node. */ 272 "id": "file:///path/to/my-package#0.1.0", 273 /* The dependencies of this package, an array of Package IDs. */ 274 "dependencies": [ 275 "https://github.com/rust-lang/crates.io-index#bitflags@1.0.4" 276 ], 277 /* The dependencies of this package. This is an alternative to 278 "dependencies" which contains additional information. In 279 particular, this handles renamed dependencies. 280 */ 281 "deps": [ 282 { 283 /* The name of the dependency's library target. 284 If this is a renamed dependency, this is the new 285 name. 286 */ 287 "name": "bitflags", 288 /* The Package ID of the dependency. */ 289 "pkg": "https://github.com/rust-lang/crates.io-index#bitflags@1.0.4" 290 /* Array of dependency kinds. Added in Cargo 1.40. */ 291 "dep_kinds": [ 292 { 293 /* The dependency kind. 294 "dev", "build", or null for a normal dependency. 295 */ 296 "kind": null, 297 /* The target platform for the dependency. 298 null if not a target dependency. 299 */ 300 "target": "cfg(windows)" 301 } 302 ] 303 } 304 ], 305 /* Array of features enabled on this package. */ 306 "features": [ 307 "default" 308 ] 309 } 310 ], 311 /* The package in the current working directory (if --manifest-path is not given). 312 This is null if there is a virtual workspace. Otherwise it is 313 the Package ID of the package. 314 */ 315 "root": "file:///path/to/my-package#0.1.0", 316 }, 317 /* The absolute path to the build directory where Cargo places its output. */ 318 "target_directory": "/path/to/my-package/target", 319 /* The version of the schema for this metadata structure. 320 This will be changed if incompatible changes are ever made. 321 */ 322 "version": 1, 323 /* The absolute path to the root of the workspace. */ 324 "workspace_root": "/path/to/my-package" 325 /* Workspace metadata. 326 This is null if no metadata is specified. */ 327 "metadata": { 328 "docs": { 329 "rs": { 330 "all-features": true 331 } 332 } 333 } 334 } 335 336 Notes: 337 338 o For "id" field syntax, see Package ID Specifications 339 <https://doc.rust-lang.org/cargo/reference/pkgid-spec.html> in the 340 reference. 341 342OPTIONS 343 Output Options 344 --no-deps 345 Output information only about the workspace members and don’t 346 fetch dependencies. 347 348 --format-version version 349 Specify the version of the output format to use. Currently 1 is the 350 only possible value. 351 352 --filter-platform triple 353 This filters the resolve output to only include dependencies for the 354 given target triple 355 <https://doc.rust-lang.org/cargo/appendix/glossary.html#target>. 356 Without this flag, the resolve includes all targets. 357 358 Note that the dependencies listed in the “packages” array still 359 includes all dependencies. Each package definition is intended to be 360 an unaltered reproduction of the information within Cargo.toml. 361 362 Feature Selection 363 The feature flags allow you to control which features are enabled. When 364 no feature options are given, the default feature is activated for every 365 selected package. 366 367 See the features documentation 368 <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options> 369 for more details. 370 371 -F features, --features features 372 Space or comma separated list of features to activate. Features of 373 workspace members may be enabled with package-name/feature-name 374 syntax. This flag may be specified multiple times, which enables all 375 specified features. 376 377 --all-features 378 Activate all available features of all selected packages. 379 380 --no-default-features 381 Do not activate the default feature of the selected packages. 382 383 Display Options 384 -v, --verbose 385 Use verbose output. May be specified twice for “very verbose” 386 output which includes extra output such as dependency warnings and 387 build script output. May also be specified with the term.verbose 388 config value 389 <https://doc.rust-lang.org/cargo/reference/config.html>. 390 391 -q, --quiet 392 Do not print cargo log messages. May also be specified with the 393 term.quiet config value 394 <https://doc.rust-lang.org/cargo/reference/config.html>. 395 396 --color when 397 Control when colored output is used. Valid values: 398 399 o auto (default): Automatically detect if color support is 400 available on the terminal. 401 402 o always: Always display colors. 403 404 o never: Never display colors. 405 406 May also be specified with the term.color config value 407 <https://doc.rust-lang.org/cargo/reference/config.html>. 408 409 Manifest Options 410 --manifest-path path 411 Path to the Cargo.toml file. By default, Cargo searches for the 412 Cargo.toml file in the current directory or any parent directory. 413 414 --locked 415 Asserts that the exact same dependencies and versions are used as 416 when the existing Cargo.lock file was originally generated. Cargo 417 will exit with an error when either of the following scenarios 418 arises: 419 420 o The lock file is missing. 421 422 o Cargo attempted to change the lock file due to a different 423 dependency resolution. 424 425 It may be used in environments where deterministic builds are 426 desired, such as in CI pipelines. 427 428 --offline 429 Prevents Cargo from accessing the network for any reason. Without 430 this flag, Cargo will stop with an error if it needs to access the 431 network and the network is not available. With this flag, Cargo will 432 attempt to proceed without the network if possible. 433 434 Beware that this may result in different dependency resolution than 435 online mode. Cargo will restrict itself to crates that are 436 downloaded locally, even if there might be a newer version as 437 indicated in the local copy of the index. See the cargo-fetch(1) 438 command to download dependencies before going offline. 439 440 May also be specified with the net.offline config value 441 <https://doc.rust-lang.org/cargo/reference/config.html>. 442 443 --frozen 444 Equivalent to specifying both --locked and --offline. 445 446 --lockfile-path PATH 447 Changes the path of the lockfile from the default 448 (<workspace_root>/Cargo.lock) to PATH. PATH must end with Cargo.lock 449 (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that 450 providing --lockfile-path will ignore existing lockfile at the 451 default path, and instead will either use the lockfile from PATH, or 452 write a new lockfile into the provided PATH if it doesn’t exist. 453 This flag can be used to run most commands in read-only directories, 454 writing lockfile into the provided PATH. 455 456 This option is only available on the nightly channel 457 <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and 458 requires the -Z unstable-options flag to enable (see #14421 459 <https://github.com/rust-lang/cargo/issues/14421>). 460 461 Common Options 462 +toolchain 463 If Cargo has been installed with rustup, and the first argument to 464 cargo begins with +, it will be interpreted as a rustup toolchain 465 name (such as +stable or +nightly). See the rustup documentation 466 <https://rust-lang.github.io/rustup/overrides.html> for more 467 information about how toolchain overrides work. 468 469 --config KEY=VALUE or PATH 470 Overrides a Cargo configuration value. The argument should be in 471 TOML syntax of KEY=VALUE, or provided as a path to an extra 472 configuration file. This flag may be specified multiple times. See 473 the command-line overrides section 474 <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides> 475 for more information. 476 477 -C PATH 478 Changes the current working directory before executing any specified 479 operations. This affects things like where cargo looks by default 480 for the project manifest (Cargo.toml), as well as the directories 481 searched for discovering .cargo/config.toml, for example. This 482 option must appear before the command name, for example cargo -C 483 path/to/my-project build. 484 485 This option is only available on the nightly channel 486 <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and 487 requires the -Z unstable-options flag to enable (see #10098 488 <https://github.com/rust-lang/cargo/issues/10098>). 489 490 -h, --help 491 Prints help information. 492 493 -Z flag 494 Unstable (nightly-only) flags to Cargo. Run cargo -Z help for 495 details. 496 497ENVIRONMENT 498 See the reference 499 <https://doc.rust-lang.org/cargo/reference/environment-variables.html> 500 for details on environment variables that Cargo reads. 501 502EXIT STATUS 503 o 0: Cargo succeeded. 504 505 o 101: Cargo failed to complete. 506 507EXAMPLES 508 1. Output JSON about the current package: 509 510 cargo metadata --format-version=1 511 512SEE ALSO 513 cargo(1), cargo-pkgid(1), Package ID Specifications 514 <https://doc.rust-lang.org/cargo/reference/pkgid-spec.html>, JSON 515 messages 516 <https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages> 517