CARGO(1)
π CARGO π
okay bestie, welcome to CARGO(1), the manual page for the Rust package manager β she's giving general commands manual energy and she's iconic. pull up a chair, we're doing this together π«Ά
β¨ NAME β¨
cargo β the Rust package manager. that's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
cargo [options] --version
cargo [options] --list
cargo [options] --help
cargo [options] --explain code
five whole ways to summon her. pick your fighter π
π¦ DESCRIPTION π¦
so this program is a package manager and build tool for the Rust language, and you can find the language herself at <https://rust-lang.org>. she builds your stuff, she fetches your stuff, she handles your whole dependency situation. main character energy, fr fr.
π COMMANDS π
okay so there are a LOT of subcommands and they're organized into little friend groups. let's meet them all π
Build Commands
cargo-bench(1)β runs benchmarks on a package. yes she will time your code. yes it's a little competitive.cargo-build(1)β compiles a package. the classic. the blueprint. the moment.cargo-check(1)β checks a local package and all its dependencies for errors, without fully building. fast bestie behaviour.cargo-clean(1)β deletes artifacts Cargo generated in the past. she's clearing her cache, literally.cargo-doc(1)β builds a package's documentation. docs queen πcargo-fetch(1)β fetches a package's dependencies from the network. bring them to me π§cargo-fix(1)β automatically fixes lint warnings reported byrustc. she's fixing your face, gently.cargo-run(1)β runs a binary or example of the local package. the "does it actually work" check.cargo-rustc(1)β compiles a package and passes extra options through to the compiler. advanced, lowkey.cargo-rustdoc(1)β builds a package's documentation using specified custom flags. same docs energy, more flags.cargo-test(1)β runs unit and integration tests of a package. the moment of truth π
Manifest Commands
cargo-generate-lockfile(1)β generatesCargo.lockfor a project.cargo-locate-project(1)β prints a JSON representation of aCargo.tomlfile's location.cargo-metadata(1)β outputs the resolved dependencies of a package in machine-readable format.cargo-pkgid(1)β prints a fully qualified package specification.cargo-tree(1)β displays a tree visualization of a dependency graph. it's giving family tree but make it crates π³cargo-update(1)β updates dependencies as recorded in the local lock file.cargo-vendor(1)β vendors all dependencies locally.cargo-verify-project(1)β checks correctness of the crate manifest.
Package Commands
cargo-init(1)β creates a new Cargo package in an existing directory.cargo-install(1)β builds and installs a Rust binary.cargo-new(1)β creates a new Cargo package. fresh start, slay.cargo-search(1)β searches packages in crates.io.cargo-uninstall(1)β removes a Rust binary. it's not you it's me π
Publishing Commands
cargo-login(1)β saves an API token from the registry locally.cargo-logout(1)β removes an API token from the registry locally.cargo-owner(1)β manages the owners of a crate on the registry.cargo-package(1)β assembles the local package into a distributable tarball.cargo-publish(1)β uploads a package to the registry. the big reveal β¨cargo-yank(1)β removes a pushed crate from the index.
General Commands
cargo-help(1)β displays help information about Cargo.cargo-version(1)β shows version information.
π OPTIONS π
Special Options
-V,--versionβ prints version info and exits. if you use it with--verbose, it prints extra information too.--listβ lists all installed Cargo subcommands. if you use it with--verbose, it prints extra information.--explain codeβ runsrustc --explain CODE, which prints out a detailed explanation of an error message (for example,E0004). it's like a translator for your compiler's emotions π
Display Options
-v,--verboseβ uses verbose output. you can specify it 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β controls when colored output is used. valid values:auto(default): automatically detects if color support is available on the terminal.always: always displays colors. πnever: never displays colors.
may also be specified with the term.color config value <https://doc.rust-lang.org/cargo/reference/config.html>.
Manifest Options
--frozen,--lockedβ either of these flags requires that theCargo.lockfile is up-to-date. if the lock file is missing, or it needs to be updated, Cargo will exit with an error. the--frozenflag also prevents Cargo from attempting to access the network to determine if it is out-of-date.
these may be used in environments where you want to assert that the Cargo.lock file is up-to-date (such as a CI build) or want to avoid network access.
--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 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 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>.
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=VALUE or PATHβ 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.
π¨ 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>). nightly besties only, sorry π
-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. (she reads a lot. she's nosy but in a helpful way π«Ά)
β 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. do not build your whole personality on it bestie.
π₯ 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. she's not perfect, she's just doing her best π«Ά
π§ SEE ALSO π§
and that's the whole page bestie!! this was the CARGO(1) page from the General Commands Manual, dated 2025-11-26, source cargo 1.92.0 β go forth and cargo build something iconic, ily, periodt πβ¨π
π¦ where this page comes from
- ubuntu jammy: cargo-1.76 1.76.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.76 1.76.0+dfsg0ubuntu1-0ubuntu0.24.04.2 Β· 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