CARGO(1)
๐ CARGO(1) โ the Rust package manager, but make it a group chat
okay bestie, welcome to CARGO(1), the manual page for cargo, aka The Rust package manager. She's in the General Commands Manual section and she is iconic. Sit down, hydrate, and let's get into it ๐ซถ
โจ NAME โจ
cargo โ The Rust package manager ๐ธ
๐ SYNOPSIS ๐
cargo [options] command [args]
cargo [options] --version
cargo [options] --list
cargo [options] --help
cargo [options] --explain code
๐ฆ DESCRIPTION ๐ฆ
So this program is a package manager and a build tool for the Rust language, and it lives at <https://rust-lang.org>. She does it all, no cap.
The command you pass in may be one of these three vibes:
- built-in commands, see below ๐
- aliases โ <https://doc.rust-lang.org/cargo/reference/config.html#alias>
- external tools โ <https://doc.rust-lang.org/cargo/reference/external-tools.html#custom-subcommands>
๐ ๏ธ COMMANDS ๐ ๏ธ
๐๏ธ Build Commands
cargo-bench(1)โ Execute benchmarks of a package. ๐cargo-build(1)โ Compile a package.cargo-check(1)โ Check a local package and all of its dependencies for errors. ๐cargo-clean(1)โ Remove artifacts that Cargo has generated in the past. ๐งนcargo-doc(1)โ Build a packageโs documentation. ๐cargo-fetch(1)โ Fetch dependencies of a package from the network. ๐cargo-fix(1)โ Automatically fix lint warnings reported byrustc. ๐งcargo-run(1)โ Run a binary or example of the local package. ๐cargo-rustc(1)โ Compile a package, and pass extra options to the compiler.cargo-rustdoc(1)โ Build a packageโs documentation, using specified custom flags.cargo-test(1)โ Execute unit and integration tests of a package. โ
๐ Manifest Commands
cargo-add(1)โ Add dependencies to aCargo.tomlmanifest file.cargo-generate-lockfile(1)โ GenerateCargo.lockfor a project.cargo-info(1)โ Display information about a package in the registry. Default registry iscrates.io.cargo-locate-project(1)โ Print a JSON representation of aCargo.tomlfileโs location.cargo-metadata(1)โ Output the resolved dependencies of a package in machine-readable format. ๐คcargo-pkgid(1)โ Print a fully qualified package specification.cargo-remove(1)โ Remove dependencies from aCargo.tomlmanifest file.cargo-tree(1)โ Display a tree visualization of a dependency graph. ๐ณcargo-update(1)โ Update dependencies as recorded in the local lock file.cargo-vendor(1)โ Vendor all dependencies locally.
๐ฆ Package Commands
cargo-init(1)โ Create a new Cargo package in an existing directory.cargo-install(1)โ Build and install a Rust binary.cargo-new(1)โ Create a new Cargo package. โจcargo-search(1)โ Search packages incrates.io.cargo-uninstall(1)โ Remove a Rust binary.
๐ Publishing Commands
cargo-login(1)โ Save an API token from the registry locally.cargo-logout(1)โ Remove an API token from the registry locally.cargo-owner(1)โ Manage the owners of a crate on the registry.cargo-package(1)โ Assemble the local package into a distributable tarball.cargo-publish(1)โ Upload a package to the registry. ๐cargo-yank(1)โ Remove a pushed crate from the index.
๐ Report Commands
cargo-report(1)โ Generate and display various kinds of reports.cargo-report-future-incompatibilities(1)โ Reports any crates which will eventually stop compiling. ๐ญ
๐งญ General Commands
cargo-help(1)โ Display help information about Cargo.cargo-version(1)โ Show version information.
โ๏ธ OPTIONS โ๏ธ
๐ Special Options
-V,--versionโ Print version info and exit. If used with--verbose, prints extra information.--listโ List all installed Cargo subcommands. If used with--verbose, prints extra information.--explain codeโ Runrustc --explain CODEwhich will print out a detailed explanation of an error message (for example,E0004). ๐ง
๐จ Display Options
-v,--verboseโ 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 theterm.verboseconfig value <https://doc.rust-lang.org/cargo/reference/config.html>. ๐ฃ๏ธ-q,--quietโ Do not print cargo log messages. May also be specified with theterm.quietconfig value <https://doc.rust-lang.org/cargo/reference/config.html>. ๐คซ--color whenโ Control when colored output is used. Valid values:auto(default): Automatically detect if color support is available on the terminal.always: Always display colors. ๐never: Never display colors.
May also be specified with the term.color config value <https://doc.rust-lang.org/cargo/reference/config.html>.
๐ Manifest Options
--lockedโ Asserts that the exact same dependencies and versions are used as when the existingCargo.lockfile was originally generated. Cargo will exit with an error when either of the following scenarios arises:- The lock file is missing.
- Cargo attempted to change the lock file due to a different dependency resolution.
It may be used in environments where deterministic builds are desired, such as in CI pipelines. ๐ฏ
--offlineโ 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.
Beware bestie โ ๏ธ 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 cargo-fetch(1) command to download dependencies before going offline.
May also be specified with the net.offline config value <https://doc.rust-lang.org/cargo/reference/config.html>.
--frozenโ Equivalent to specifying both--lockedand--offline. โ๏ธ
๐ซถ Common Options
+toolchainโ If Cargo has been installed with rustup, and the first argument tocargobegins with+, it will be interpreted as a rustup toolchain name (such as+stableor+nightly). See the rustup documentation <https://rust-lang.github.io/rustup/overrides.html> for more information about how toolchain overrides work.--config KEY=VALUEorPATHโ Overrides a Cargo configuration value. The argument should be in TOML syntax ofKEY=VALUE, or provided as a path to an extra configuration file. This flag may be specified multiple times. See the command-line overrides section <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides> for more information.-C PATHโ Changes the current working directory before executing any specified operations. This affects things like where cargo looks by default for the project manifest (Cargo.toml), as well as the directories searched for discovering.cargo/config.toml, for example. This option must appear before the command name, for examplecargo -C path/to/my-project build.
heads up ๐ This option is only available on the nightly channel <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and requires the -Z unstable-options flag to enable (see #10098 <https://github.com/rust-lang/cargo/issues/10098>).
-h,--helpโ Prints help information. ๐-Z flagโ Unstable (nightly-only) flags to Cargo. Runcargo -Z helpfor details. ๐
๐ ENVIRONMENT ๐
See the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. ๐
๐ฆ EXIT STATUS ๐ฆ
0: Cargo succeeded. ๐101: Cargo failed to complete. ๐
๐ FILES ๐
~/.cargo/โ Default location for Cargoโs โhomeโ directory where it stores various files. The location can be changed with theCARGO_HOMEenvironment variable.$CARGO_HOME/bin/โ Binaries installed bycargo-install(1)will be located here. If using rustup <https://rust-lang.github.io/rustup/>, executables distributed with Rust are also located here.$CARGO_HOME/config.tomlโ The global configuration file. See the reference <https://doc.rust-lang.org/cargo/reference/config.html> for more information about configuration files..cargo/config.tomlโ Cargo automatically searches for a file named.cargo/config.tomlin the current directory, and all parent directories. These configuration files will be merged with the global configuration file.$CARGO_HOME/credentials.tomlโ Private authentication information for logging in to a registry. ๐$CARGO_HOME/registry/โ This directory contains cached downloads of the registry index and any downloaded dependencies.$CARGO_HOME/git/โ This directory contains cached downloads of git dependencies.
Please note that the internal structure of the $CARGO_HOME directory is not stable yet and may be subject to change. ๐ซ
๐ธ EXAMPLES ๐ธ
- Build a local package and all of its dependencies:
cargo build
- Build a package with optimizations:
cargo build --release
- Run tests for a cross-compiled target:
cargo test --target i686-unknown-linux-gnu
- Create a new package that builds an executable:
cargo new foobar
- Create a package in the current directory:
mkdir foo && cd foo
cargo init .
- Learn about a commandโs options and usage:
cargo help clean
๐ BUGS ๐
See <https://github.com/rust-lang/cargo/issues> for issues. fr fr, if something's broken, that's the place ๐ซก
๐ SEE ALSO ๐
and that's the whole page bestie ๐ this was the CARGO(1) page from the General Commands Manual โ footer says CARGO(1) too, so yeah, she's got main character energy from top to bottom ๐ go build something cute, mwah ๐โจ
๐ฆ where this page comes from
- ubuntu stonking: cargo-1.96 1.96.1+dfsg-0ubuntu1 ยท MIT OR Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms