543 lines
21 KiB
Groff
543 lines
21 KiB
Groff
'\" t
|
|
.TH "CARGO\-METADATA" "1"
|
|
.nh
|
|
.ad l
|
|
.ss \n[.ss] 0
|
|
.SH "NAME"
|
|
cargo\-metadata \[em] Machine\-readable metadata about the current package
|
|
.SH "SYNOPSIS"
|
|
\fBcargo metadata\fR [\fIoptions\fR]
|
|
.SH "DESCRIPTION"
|
|
Output JSON to stdout containing information about the workspace members and
|
|
resolved dependencies of the current package.
|
|
.sp
|
|
The format of the output is subject to change in futures versions of Cargo. It
|
|
is recommended to include the \fB\-\-format\-version\fR flag to future\-proof your code
|
|
to ensure the output is in the format you are expecting. For more on the
|
|
expectations, see \[lq]Compatibility\[rq]\&.
|
|
.sp
|
|
See the \fIcargo_metadata crate\fR <https://crates.io/crates/cargo_metadata>
|
|
for a Rust API for reading the metadata.
|
|
.SH "OUTPUT FORMAT"
|
|
.SS "Compatibility"
|
|
Within the same output format version, the compatibility is maintained, except
|
|
some scenarios. The following is a non\-exhaustive list of changes that are not
|
|
considersed as incompatible:
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'\fBAdding new fields\fR \[em] New fields will be added when needed. Reserving this
|
|
helps Cargo evolve without bumping the format version too often.
|
|
.RE
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'\fBAdding new values for enum\-like fields\fR \[em] Same as adding new fields. It
|
|
keeps metadata evolving without stagnation.
|
|
.RE
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'\fBChanging opaque representations\fR \[em] The inner representations of some
|
|
fields are implementation details. For example, fields related to
|
|
\[lq]Source ID\[rq] are treated as opaque identifiers to differentiate packages or
|
|
sources. Consumers shouldn\[cq]t rely on those representations unless specified.
|
|
.RE
|
|
.SS "JSON format"
|
|
The JSON output has the following format:
|
|
.sp
|
|
.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 for referring to the
|
|
package within the document and as the `\-\-package` argument to many commands
|
|
*/
|
|
"id": "file:///path/to/my\-package#0.1.0",
|
|
/* 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, an "opaque" identifier representing
|
|
where a package is retrieved from. See "Compatibility" above for
|
|
the stability guarantee.
|
|
|
|
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"
|
|
\- "sparse+URL" for dependencies from a sparse registry
|
|
Example: "sparse+https://my\-sparse\-registry.org"
|
|
|
|
The value after the `+` is not explicitly defined, and may change
|
|
between versions of Cargo and may not directly correlate to other
|
|
things, such as registry definitions in a config file. New source
|
|
kinds may be added in the future which will have different `+`
|
|
prefixed identifiers.
|
|
*/
|
|
"source": null,
|
|
/* Array of dependencies declared in the package's 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)",
|
|
/* The file system path for a local path dependency.
|
|
not present if not a path dependency.
|
|
*/
|
|
"path": "/path/to/dep",
|
|
/* 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 the target should be documented by `cargo doc`. */
|
|
"doc": true,
|
|
/* Whether or not this target has doc tests enabled, and
|
|
the target is compatible with doc testing.
|
|
*/
|
|
"doctest": false,
|
|
/* Whether or not this target should be built and run with `\-\-test`
|
|
*/
|
|
"test": true
|
|
}
|
|
],
|
|
/* 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's 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 <user@example.com>"
|
|
],
|
|
/* Array of categories from the manifest. */
|
|
"categories": [
|
|
"command\-line\-utilities"
|
|
],
|
|
/* Optional string that is the default binary picked by cargo run. */
|
|
"default_run": null,
|
|
/* Optional string that is the minimum supported rust version */
|
|
"rust_version": "1.56",
|
|
/* 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 homepage value from the manifest or null if not specified. */
|
|
"homepage": "https://rust\-lang.org",
|
|
/* The documentation value from the manifest or null if not specified. */
|
|
"documentation": "https://doc.rust\-lang.org/stable/std",
|
|
/* 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": [
|
|
"file:///path/to/my\-package#0.1.0",
|
|
],
|
|
/* Array of default members of the workspace.
|
|
Each entry is the Package ID for the package.
|
|
*/
|
|
"workspace_default_members": [
|
|
"file:///path/to/my\-package#0.1.0",
|
|
],
|
|
// 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": "file:///path/to/my\-package#0.1.0",
|
|
/* The dependencies of this package, an array of Package IDs. */
|
|
"dependencies": [
|
|
"https://github.com/rust\-lang/crates.io\-index#bitflags@1.0.4"
|
|
],
|
|
/* 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's library target.
|
|
If this is a renamed dependency, this is the new
|
|
name.
|
|
*/
|
|
"name": "bitflags",
|
|
/* The Package ID of the dependency. */
|
|
"pkg": "https://github.com/rust\-lang/crates.io\-index#bitflags@1.0.4"
|
|
/* 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": "file:///path/to/my\-package#0.1.0",
|
|
},
|
|
/* 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
|
|
.RE
|
|
.sp
|
|
Notes:
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'For \fB"id"\fR field syntax, see \fIPackage ID Specifications\fR <https://doc.rust\-lang.org/cargo/reference/pkgid\-spec.html> in the reference.
|
|
.RE
|
|
.SH "OPTIONS"
|
|
.SS "Output Options"
|
|
.sp
|
|
\fB\-\-no\-deps\fR
|
|
.RS 4
|
|
Output information only about the workspace members and don\[cq]t fetch
|
|
dependencies.
|
|
.RE
|
|
.sp
|
|
\fB\-\-format\-version\fR \fIversion\fR
|
|
.RS 4
|
|
Specify the version of the output format to use. Currently \fB1\fR is the only
|
|
possible value.
|
|
.RE
|
|
.sp
|
|
\fB\-\-filter\-platform\fR \fItriple\fR
|
|
.RS 4
|
|
This filters the \fBresolve\fR output to only include dependencies for the
|
|
given \fItarget triple\fR <https://doc.rust\-lang.org/cargo/appendix/glossary.html#target>\&.
|
|
Without this flag, the resolve includes all targets.
|
|
.sp
|
|
Note that the dependencies listed in the \[lq]packages\[rq] array still includes all
|
|
dependencies. Each package definition is intended to be an unaltered
|
|
reproduction of the information within \fBCargo.toml\fR\&.
|
|
.RE
|
|
.SS "Feature Selection"
|
|
The feature flags allow you to control which features are enabled. When no
|
|
feature options are given, the \fBdefault\fR feature is activated for every
|
|
selected package.
|
|
.sp
|
|
See \fIthe features documentation\fR <https://doc.rust\-lang.org/cargo/reference/features.html#command\-line\-feature\-options>
|
|
for more details.
|
|
.sp
|
|
\fB\-F\fR \fIfeatures\fR,
|
|
\fB\-\-features\fR \fIfeatures\fR
|
|
.RS 4
|
|
Space or comma separated list of features to activate. Features of workspace
|
|
members may be enabled with \fBpackage\-name/feature\-name\fR syntax. This flag may
|
|
be specified multiple times, which enables all specified features.
|
|
.RE
|
|
.sp
|
|
\fB\-\-all\-features\fR
|
|
.RS 4
|
|
Activate all available features of all selected packages.
|
|
.RE
|
|
.sp
|
|
\fB\-\-no\-default\-features\fR
|
|
.RS 4
|
|
Do not activate the \fBdefault\fR feature of the selected packages.
|
|
.RE
|
|
.SS "Display Options"
|
|
.sp
|
|
\fB\-v\fR,
|
|
\fB\-\-verbose\fR
|
|
.RS 4
|
|
Use verbose output. May be specified twice for \[lq]very verbose\[rq] output which
|
|
includes extra output such as dependency warnings and build script output.
|
|
May also be specified with the \fBterm.verbose\fR
|
|
\fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&.
|
|
.RE
|
|
.sp
|
|
\fB\-q\fR,
|
|
\fB\-\-quiet\fR
|
|
.RS 4
|
|
Do not print cargo log messages.
|
|
May also be specified with the \fBterm.quiet\fR
|
|
\fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&.
|
|
.RE
|
|
.sp
|
|
\fB\-\-color\fR \fIwhen\fR
|
|
.RS 4
|
|
Control when colored output is used. Valid values:
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'\fBauto\fR (default): Automatically detect if color support is available on the
|
|
terminal.
|
|
.RE
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'\fBalways\fR: Always display colors.
|
|
.RE
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'\fBnever\fR: Never display colors.
|
|
.RE
|
|
.sp
|
|
May also be specified with the \fBterm.color\fR
|
|
\fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&.
|
|
.RE
|
|
.SS "Manifest Options"
|
|
.sp
|
|
\fB\-\-manifest\-path\fR \fIpath\fR
|
|
.RS 4
|
|
Path to the \fBCargo.toml\fR file. By default, Cargo searches for the
|
|
\fBCargo.toml\fR file in the current directory or any parent directory.
|
|
.RE
|
|
.sp
|
|
\fB\-\-locked\fR
|
|
.RS 4
|
|
Asserts that the exact same dependencies and versions are used as when the
|
|
existing \fBCargo.lock\fR file was originally generated. Cargo will exit with an
|
|
error when either of the following scenarios arises:
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'The lock file is missing.
|
|
.RE
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'Cargo attempted to change the lock file due to a different dependency resolution.
|
|
.RE
|
|
.sp
|
|
It may be used in environments where deterministic builds are desired,
|
|
such as in CI pipelines.
|
|
.RE
|
|
.sp
|
|
\fB\-\-offline\fR
|
|
.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\fR(1) command to download dependencies before going
|
|
offline.
|
|
.sp
|
|
May also be specified with the \fBnet.offline\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&.
|
|
.RE
|
|
.sp
|
|
\fB\-\-frozen\fR
|
|
.RS 4
|
|
Equivalent to specifying both \fB\-\-locked\fR and \fB\-\-offline\fR\&.
|
|
.RE
|
|
.SS "Common Options"
|
|
.sp
|
|
\fB+\fR\fItoolchain\fR
|
|
.RS 4
|
|
If Cargo has been installed with rustup, and the first argument to \fBcargo\fR
|
|
begins with \fB+\fR, it will be interpreted as a rustup toolchain name (such
|
|
as \fB+stable\fR or \fB+nightly\fR).
|
|
See the \fIrustup documentation\fR <https://rust\-lang.github.io/rustup/overrides.html>
|
|
for more information about how toolchain overrides work.
|
|
.RE
|
|
.sp
|
|
\fB\-\-config\fR \fIKEY=VALUE\fR or \fIPATH\fR
|
|
.RS 4
|
|
Overrides a Cargo configuration value. The argument should be in TOML syntax of \fBKEY=VALUE\fR,
|
|
or provided as a path to an extra configuration file. This flag may be specified multiple times.
|
|
See the \fIcommand\-line overrides section\fR <https://doc.rust\-lang.org/cargo/reference/config.html#command\-line\-overrides> for more information.
|
|
.RE
|
|
.sp
|
|
\fB\-C\fR \fIPATH\fR
|
|
.RS 4
|
|
Changes the current working directory before executing any specified operations. This affects
|
|
things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as
|
|
the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. This option must
|
|
appear before the command name, for example \fBcargo \-C path/to/my\-project build\fR\&.
|
|
.sp
|
|
This option is only available on the \fInightly
|
|
channel\fR <https://doc.rust\-lang.org/book/appendix\-07\-nightly\-rust.html> and
|
|
requires the \fB\-Z unstable\-options\fR flag to enable (see
|
|
\fI#10098\fR <https://github.com/rust\-lang/cargo/issues/10098>).
|
|
.RE
|
|
.sp
|
|
\fB\-h\fR,
|
|
\fB\-\-help\fR
|
|
.RS 4
|
|
Prints help information.
|
|
.RE
|
|
.sp
|
|
\fB\-Z\fR \fIflag\fR
|
|
.RS 4
|
|
Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fR for details.
|
|
.RE
|
|
.SH "ENVIRONMENT"
|
|
See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
|
|
details on environment variables that Cargo reads.
|
|
.SH "EXIT STATUS"
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'\fB0\fR: Cargo succeeded.
|
|
.RE
|
|
.sp
|
|
.RS 4
|
|
\h'-04'\(bu\h'+02'\fB101\fR: Cargo failed to complete.
|
|
.RE
|
|
.SH "EXAMPLES"
|
|
.sp
|
|
.RS 4
|
|
\h'-04' 1.\h'+01'Output JSON about the current package:
|
|
.sp
|
|
.RS 4
|
|
.nf
|
|
cargo metadata \-\-format\-version=1
|
|
.fi
|
|
.RE
|
|
.RE
|
|
.SH "SEE ALSO"
|
|
\fBcargo\fR(1), \fBcargo\-pkgid\fR(1), \fIPackage ID Specifications\fR <https://doc.rust\-lang.org/cargo/reference/pkgid\-spec.html>, \fIJSON messages\fR <https://doc.rust\-lang.org/cargo/reference/external\-tools.html#json\-messages>
|