| '\" t |
| .TH "CARGO" "1" |
| .nh |
| .ad l |
| .ss \n[.ss] 0 |
| .SH "NAME" |
| cargo \[em] The Rust package manager |
| .SH "SYNOPSIS" |
| \fBcargo\fR [\fIoptions\fR] \fIcommand\fR [\fIargs\fR] |
| .br |
| \fBcargo\fR [\fIoptions\fR] \fB\-\-version\fR |
| .br |
| \fBcargo\fR [\fIoptions\fR] \fB\-\-list\fR |
| .br |
| \fBcargo\fR [\fIoptions\fR] \fB\-\-help\fR |
| .br |
| \fBcargo\fR [\fIoptions\fR] \fB\-\-explain\fR \fIcode\fR |
| .SH "DESCRIPTION" |
| This program is a package manager and build tool for the Rust language, |
| available at <https://rust\-lang.org>\&. |
| .SH "COMMANDS" |
| .SS "Build Commands" |
| \fBcargo\-bench\fR(1) |
| .br |
| \ \ \ \ Execute benchmarks of a package. |
| .sp |
| \fBcargo\-build\fR(1) |
| .br |
| \ \ \ \ Compile a package. |
| .sp |
| \fBcargo\-check\fR(1) |
| .br |
| \ \ \ \ Check a local package and all of its dependencies for errors. |
| .sp |
| \fBcargo\-clean\fR(1) |
| .br |
| \ \ \ \ Remove artifacts that Cargo has generated in the past. |
| .sp |
| \fBcargo\-doc\fR(1) |
| .br |
| \ \ \ \ Build a package\[cq]s documentation. |
| .sp |
| \fBcargo\-fetch\fR(1) |
| .br |
| \ \ \ \ Fetch dependencies of a package from the network. |
| .sp |
| \fBcargo\-fix\fR(1) |
| .br |
| \ \ \ \ Automatically fix lint warnings reported by rustc. |
| .sp |
| \fBcargo\-run\fR(1) |
| .br |
| \ \ \ \ Run a binary or example of the local package. |
| .sp |
| \fBcargo\-rustc\fR(1) |
| .br |
| \ \ \ \ Compile a package, and pass extra options to the compiler. |
| .sp |
| \fBcargo\-rustdoc\fR(1) |
| .br |
| \ \ \ \ Build a package\[cq]s documentation, using specified custom flags. |
| .sp |
| \fBcargo\-test\fR(1) |
| .br |
| \ \ \ \ Execute unit and integration tests of a package. |
| .SS "Manifest Commands" |
| \fBcargo\-generate\-lockfile\fR(1) |
| .br |
| \ \ \ \ Generate \fBCargo.lock\fR for a project. |
| .sp |
| \fBcargo\-locate\-project\fR(1) |
| .br |
| \ \ \ \ Print a JSON representation of a \fBCargo.toml\fR file\[cq]s location. |
| .sp |
| \fBcargo\-metadata\fR(1) |
| .br |
| \ \ \ \ Output the resolved dependencies of a package in machine\-readable format. |
| .sp |
| \fBcargo\-pkgid\fR(1) |
| .br |
| \ \ \ \ Print a fully qualified package specification. |
| .sp |
| \fBcargo\-tree\fR(1) |
| .br |
| \ \ \ \ Display a tree visualization of a dependency graph. |
| .sp |
| \fBcargo\-update\fR(1) |
| .br |
| \ \ \ \ Update dependencies as recorded in the local lock file. |
| .sp |
| \fBcargo\-vendor\fR(1) |
| .br |
| \ \ \ \ Vendor all dependencies locally. |
| .sp |
| \fBcargo\-verify\-project\fR(1) |
| .br |
| \ \ \ \ Check correctness of crate manifest. |
| .SS "Package Commands" |
| \fBcargo\-init\fR(1) |
| .br |
| \ \ \ \ Create a new Cargo package in an existing directory. |
| .sp |
| \fBcargo\-install\fR(1) |
| .br |
| \ \ \ \ Build and install a Rust binary. |
| .sp |
| \fBcargo\-new\fR(1) |
| .br |
| \ \ \ \ Create a new Cargo package. |
| .sp |
| \fBcargo\-search\fR(1) |
| .br |
| \ \ \ \ Search packages in crates.io. |
| .sp |
| \fBcargo\-uninstall\fR(1) |
| .br |
| \ \ \ \ Remove a Rust binary. |
| .SS "Publishing Commands" |
| \fBcargo\-login\fR(1) |
| .br |
| \ \ \ \ Save an API token from the registry locally. |
| .sp |
| \fBcargo\-owner\fR(1) |
| .br |
| \ \ \ \ Manage the owners of a crate on the registry. |
| .sp |
| \fBcargo\-package\fR(1) |
| .br |
| \ \ \ \ Assemble the local package into a distributable tarball. |
| .sp |
| \fBcargo\-publish\fR(1) |
| .br |
| \ \ \ \ Upload a package to the registry. |
| .sp |
| \fBcargo\-yank\fR(1) |
| .br |
| \ \ \ \ Remove a pushed crate from the index. |
| .SS "General Commands" |
| \fBcargo\-help\fR(1) |
| .br |
| \ \ \ \ Display help information about Cargo. |
| .sp |
| \fBcargo\-version\fR(1) |
| .br |
| \ \ \ \ Show version information. |
| .SH "OPTIONS" |
| .SS "Special Options" |
| .sp |
| \fB\-V\fR, |
| \fB\-\-version\fR |
| .RS 4 |
| Print version info and exit. If used with \fB\-\-verbose\fR, prints extra |
| information. |
| .RE |
| .sp |
| \fB\-\-list\fR |
| .RS 4 |
| List all installed Cargo subcommands. If used with \fB\-\-verbose\fR, prints extra |
| information. |
| .RE |
| .sp |
| \fB\-\-explain\fR \fIcode\fR |
| .RS 4 |
| Run \fBrustc \-\-explain CODE\fR which will print out a detailed explanation of an |
| error message (for example, \fBE0004\fR). |
| .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\-\-frozen\fR, |
| \fB\-\-locked\fR |
| .RS 4 |
| Either of these flags requires that the \fBCargo.lock\fR 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\fR 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\fR file is up\-to\-date (such as a CI build) or want to avoid network |
| access. |
| .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 |
| .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. |
| .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 "FILES" |
| \fB~/.cargo/\fR |
| .br |
| \ \ \ \ Default location for Cargo\[cq]s \[lq]home\[rq] directory where it |
| stores various files. The location can be changed with the \fBCARGO_HOME\fR |
| environment variable. |
| .sp |
| \fB$CARGO_HOME/bin/\fR |
| .br |
| \ \ \ \ Binaries installed by \fBcargo\-install\fR(1) will be located here. If using |
| \fIrustup\fR <https://rust\-lang.github.io/rustup/>, executables distributed with Rust are also located here. |
| .sp |
| \fB$CARGO_HOME/config.toml\fR |
| .br |
| \ \ \ \ The global configuration file. See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/config.html> |
| for more information about configuration files. |
| .sp |
| \fB\&.cargo/config.toml\fR |
| .br |
| \ \ \ \ Cargo automatically searches for a file named \fB\&.cargo/config.toml\fR in the |
| current directory, and all parent directories. These configuration files |
| will be merged with the global configuration file. |
| .sp |
| \fB$CARGO_HOME/credentials.toml\fR |
| .br |
| \ \ \ \ Private authentication information for logging in to a registry. |
| .sp |
| \fB$CARGO_HOME/registry/\fR |
| .br |
| \ \ \ \ This directory contains cached downloads of the registry index and any |
| downloaded dependencies. |
| .sp |
| \fB$CARGO_HOME/git/\fR |
| .br |
| \ \ \ \ This directory contains cached downloads of git dependencies. |
| .sp |
| Please note that the internal structure of the \fB$CARGO_HOME\fR directory is not |
| stable yet and may be subject to change. |
| .SH "EXAMPLES" |
| .sp |
| .RS 4 |
| \h'-04' 1.\h'+01'Build a local package and all of its dependencies: |
| .sp |
| .RS 4 |
| .nf |
| cargo build |
| .fi |
| .RE |
| .RE |
| .sp |
| .RS 4 |
| \h'-04' 2.\h'+01'Build a package with optimizations: |
| .sp |
| .RS 4 |
| .nf |
| cargo build \-\-release |
| .fi |
| .RE |
| .RE |
| .sp |
| .RS 4 |
| \h'-04' 3.\h'+01'Run tests for a cross\-compiled target: |
| .sp |
| .RS 4 |
| .nf |
| cargo test \-\-target i686\-unknown\-linux\-gnu |
| .fi |
| .RE |
| .RE |
| .sp |
| .RS 4 |
| \h'-04' 4.\h'+01'Create a new package that builds an executable: |
| .sp |
| .RS 4 |
| .nf |
| cargo new foobar |
| .fi |
| .RE |
| .RE |
| .sp |
| .RS 4 |
| \h'-04' 5.\h'+01'Create a package in the current directory: |
| .sp |
| .RS 4 |
| .nf |
| mkdir foo && cd foo |
| cargo init . |
| .fi |
| .RE |
| .RE |
| .sp |
| .RS 4 |
| \h'-04' 6.\h'+01'Learn about a command\[cq]s options and usage: |
| .sp |
| .RS 4 |
| .nf |
| cargo help clean |
| .fi |
| .RE |
| .RE |
| .SH "BUGS" |
| See <https://github.com/rust\-lang/cargo/issues> for issues. |
| .SH "SEE ALSO" |
| \fBrustc\fR(1), \fBrustdoc\fR(1) |