'\" t .\" Title: cargo-metadata .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.10 .\" Date: 2020-07-04 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" .TH "CARGO\-METADATA" "1" "2020-07-04" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" cargo\-metadata \- Machine\-readable metadata about the current package .SH "SYNOPSIS" .sp \fBcargo metadata [\fIOPTIONS\fP]\fP .SH "DESCRIPTION" .sp Output JSON to stdout containing information about the workspace members and resolved dependencies of the current package. .sp It is recommended to include the \fB\-\-format\-version\fP flag to future\-proof your code to ensure the output is in the format you are expecting. .sp See the \c .URL "https://crates.io/crates/cargo_metadata" "cargo_metadata crate" for a Rust API for reading the metadata. .SH "OUTPUT FORMAT" .sp The output has the following format: .sp .if n .RS 4 .nf { /* Array of all packages in the workspace. It also includes all feature\-enabled dependencies unless \-\-no\-deps is used. */ "packages": [ { /* The name of the package. */ "name": "my\-package", /* The version of the package. */ "version": "0.1.0", /* The Package ID, a unique identifier for referring to the package. */ "id": "my\-package 0.1.0 (path+file:///path/to/my\-package)", /* The license value from the manifest, or null. */ "license": "MIT/Apache\-2.0", /* The license\-file value from the manifest, or null. */ "license_file": "LICENSE", /* The description value from the manifest, or null. */ "description": "Package description.", /* The source ID of the package. This represents where a package is retrieved from. This is null for path dependencies and workspace members. For other dependencies, it is a string with the format: \- "registry+URL" for registry\-based dependencies. Example: "registry+https://github.com/rust\-lang/crates.io\-index" \- "git+URL" for git\-based dependencies. Example: "git+https://github.com/rust\-lang/cargo?rev=5e85ba14aaa20f8133863373404cb0af69eeef2c#5e85ba14aaa20f8133863373404cb0af69eeef2c" */ "source": null, /* Array of dependencies declared in the package\(aqs manifest. */ "dependencies": [ { /* The name of the dependency. */ "name": "bitflags", /* The source ID of the dependency. May be null, see description for the package source. */ "source": "registry+https://github.com/rust\-lang/crates.io\-index", /* The version requirement for the dependency. Dependencies without a version requirement have a value of "*". */ "req": "^1.0", /* The dependency kind. "dev", "build", or null for a normal dependency. */ "kind": null, /* If the dependency is renamed, this is the new name for the dependency as a string. null if it is not renamed. */ "rename": null, /* Boolean of whether or not this is an optional dependency. */ "optional": false, /* Boolean of whether or not default features are enabled. */ "uses_default_features": true, /* Array of features enabled. */ "features": [], /* The target platform for the dependency. null if not a target dependency. */ "target": "cfg(windows)", /* A string of the URL of the registry this dependency is from. If not specified or null, the dependency is from the default registry (crates.io). */ "registry": null } ], /* Array of Cargo targets. */ "targets": [ { /* Array of target kinds. \- lib targets list the `crate\-type` values from the manifest such as "lib", "rlib", "dylib", "proc\-macro", etc. (default ["lib"]) \- binary is ["bin"] \- example is ["example"] \- integration test is ["test"] \- benchmark is ["bench"] \- build script is ["custom\-build"] */ "kind": [ "bin" ], /* Array of crate types. \- lib and example libraries list the `crate\-type` values from the manifest such as "lib", "rlib", "dylib", "proc\-macro", etc. (default ["lib"]) \- all other target kinds are ["bin"] */ "crate_types": [ "bin" ], /* The name of the target. */ "name": "my\-package", /* Absolute path to the root source file of the target. */ "src_path": "/path/to/my\-package/src/main.rs", /* The Rust edition of the target. Defaults to the package edition. */ "edition": "2018", /* Array of required features. This property is not included if no required features are set. */ "required\-features": ["feat1"], /* Whether or not this target has doc tests enabled, and the target is compatible with doc testing. */ "doctest": false } ], /* Set of features defined for the package. Each feature maps to an array of features or dependencies it enables. */ "features": { "default": [ "feat1" ], "feat1": [], "feat2": [] }, /* Absolute path to this package\(aqs manifest. */ "manifest_path": "/path/to/my\-package/Cargo.toml", /* Package metadata. This is null if no metadata is specified. */ "metadata": { "docs": { "rs": { "all\-features": true } } }, /* List of registries to which this package may be published. Publishing is unrestricted if null, and forbidden if an empty array. */ "publish": [ "crates\-io" ], /* Array of authors from the manifest. Empty array if no authors specified. */ "authors": [ "Jane Doe " ], /* Array of categories from the manifest. */ "categories": [ "command\-line\-utilities" ], /* Array of keywords from the manifest. */ "keywords": [ "cli" ], /* The readme value from the manifest or null if not specified. */ "readme": "README.md", /* The repository value from the manifest or null if not specified. */ "repository": "https://github.com/rust\-lang/cargo", /* The default edition of the package. Note that individual targets may have different editions. */ "edition": "2018", /* Optional string that is the name of a native library the package is linking to. */ "links": null, } ], /* Array of members of the workspace. Each entry is the Package ID for the package. */ "workspace_members": [ "my\-package 0.1.0 (path+file:///path/to/my\-package)", ], // The resolved dependency graph for the entire workspace. The enabled // features are based on the enabled features for the "current" package. // Inactivated optional dependencies are not listed. // // This is null if \-\-no\-deps is specified. // // By default, this includes all dependencies for all target platforms. // The `\-\-filter\-platform` flag may be used to narrow to a specific // target triple. "resolve": { /* Array of nodes within the dependency graph. Each node is a package. */ "nodes": [ { /* The Package ID of this node. */ "id": "my\-package 0.1.0 (path+file:///path/to/my\-package)", /* The dependencies of this package, an array of Package IDs. */ "dependencies": [ "bitflags 1.0.4 (registry+https://github.com/rust\-lang/crates.io\-index)" ], /* The dependencies of this package. This is an alternative to "dependencies" which contains additional information. In particular, this handles renamed dependencies. */ "deps": [ { /* The name of the dependency\(aqs library target. If this is a renamed dependency, this is the new name. */ "name": "bitflags", /* The Package ID of the dependency. */ "pkg": "bitflags 1.0.4 (registry+https://github.com/rust\-lang/crates.io\-index)", /* Array of dependency kinds. Added in Cargo 1.40. */ "dep_kinds": [ { /* The dependency kind. "dev", "build", or null for a normal dependency. */ "kind": null, /* The target platform for the dependency. null if not a target dependency. */ "target": "cfg(windows)" } ] } ], /* Array of features enabled on this package. */ "features": [ "default" ] } ], /* The root package of the workspace. This is null if this is a virtual workspace. Otherwise it is the Package ID of the root package. */ "root": "my\-package 0.1.0 (path+file:///path/to/my\-package)" }, /* The absolute path to the build directory where Cargo places its output. */ "target_directory": "/path/to/my\-package/target", /* The version of the schema for this metadata structure. This will be changed if incompatible changes are ever made. */ "version": 1, /* The absolute path to the root of the workspace. */ "workspace_root": "/path/to/my\-package" /* Workspace metadata. This is null if no metadata is specified. */ "metadata": { "docs": { "rs": { "all\-features": true } } } } .fi .if n .RE .SH "OPTIONS" .SS "Output Options" .sp \fB\-\-no\-deps\fP .RS 4 Output information only about the workspace members and don\(cqt fetch dependencies. .RE .sp \fB\-\-format\-version\fP \fIVERSION\fP .RS 4 Specify the version of the output format to use. Currently \fB1\fP is the only possible value. .RE .sp \fB\-\-filter\-platform\fP \fITRIPLE\fP .RS 4 This filters the \fBresolve\fP output to only include dependencies for the given target triple. Without this flag, the resolve includes all targets. .sp Note that the dependencies listed in the "packages" array still includes all dependencies. Each package definition is intended to be an unaltered reproduction of the information within \fBCargo.toml\fP. .RE .SS "Feature Selection" .sp The feature flags allow you to control the enabled features for the "current" package. The "current" package is the package in the current directory, or the one specified in \fB\-\-manifest\-path\fP. If running in the root of a virtual workspace, then the default features are selected for all workspace members, or all features if \fB\-\-all\-features\fP is specified. .sp When no feature options are given, the \fBdefault\fP feature is activated for every selected package. .sp \fB\-\-features\fP \fIFEATURES\fP .RS 4 Space or comma separated list of features to activate. These features only apply to the current directory\(cqs package. Features of direct dependencies may be enabled with \fB/\fP syntax. This flag may be specified multiple times, which enables all specified features. .RE .sp \fB\-\-all\-features\fP .RS 4 Activate all available features of all selected packages. .RE .sp \fB\-\-no\-default\-features\fP .RS 4 Do not activate the \fBdefault\fP feature of the current directory\(cqs package. .RE .SS "Display Options" .sp \fB\-v\fP, \fB\-\-verbose\fP .RS 4 Use verbose output. May be specified twice for "very verbose" output which includes extra output such as dependency warnings and build script output. May also be specified with the \fBterm.verbose\fP .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." .RE .sp \fB\-q\fP, \fB\-\-quiet\fP .RS 4 No output printed to stdout. .RE .sp \fB\-\-color\fP \fIWHEN\fP .RS 4 Control when colored output is used. Valid values: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fBauto\fP (default): Automatically detect if color support is available on the terminal. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fBalways\fP: Always display colors. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} \fBnever\fP: Never display colors. .RE .sp May also be specified with the \fBterm.color\fP .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." .RE .SS "Manifest Options" .sp \fB\-\-manifest\-path\fP \fIPATH\fP .RS 4 Path to the \fBCargo.toml\fP file. By default, Cargo searches for the \fBCargo.toml\fP file in the current directory or any parent directory. .RE .sp \fB\-\-frozen\fP, \fB\-\-locked\fP .RS 4 Either of these flags requires that the \fBCargo.lock\fP file is up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from attempting to access the network to determine if it is out\-of\-date. .sp These may be used in environments where you want to assert that the \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network access. .RE .sp \fB\-\-offline\fP .RS 4 Prevents Cargo from accessing the network for any reason. Without this flag, Cargo will stop with an error if it needs to access the network and the network is not available. With this flag, Cargo will attempt to proceed without the network if possible. .sp Beware that this may result in different dependency resolution than online mode. Cargo will restrict itself to crates that are downloaded locally, even if there might be a newer version as indicated in the local copy of the index. See the \fBcargo\-fetch\fP(1) command to download dependencies before going offline. .sp May also be specified with the \fBnet.offline\fP \c .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." .RE .SS "Common Options" .sp \fB+TOOLCHAIN\fP .RS 4 If Cargo has been installed with rustup, and the first argument to \fBcargo\fP begins with \fB+\fP, it will be interpreted as a rustup toolchain name (such as \fB+stable\fP or \fB+nightly\fP). See the \c .URL "https://github.com/rust\-lang/rustup/" "rustup documentation" for more information about how toolchain overrides work. .RE .sp \fB\-h\fP, \fB\-\-help\fP .RS 4 Prints help information. .RE .sp \fB\-Z\fP \fIFLAG\fP... .RS 4 Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for details. .RE .SH "ENVIRONMENT" .sp See \c .URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " " for details on environment variables that Cargo reads. .SH "EXIT STATUS" .sp 0 .RS 4 Cargo succeeded. .RE .sp 101 .RS 4 Cargo failed to complete. .RE .SH "EXAMPLES" .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ . sp -1 . IP " 1." 4.2 .\} Output JSON about the current package: .sp .if n .RS 4 .nf cargo metadata \-\-format\-version=1 .fi .if n .RE .RE .SH "SEE ALSO" .sp \fBcargo\fP(1)