CARGO(1)

πŸ“¦ version 1.77.2, in ubuntu jammy, ubuntu noble

πŸ’– 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 by rustc. 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

Package Commands

Publishing Commands

General Commands


πŸ’… 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 β€” runs rustc --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 the term.verbose config value <https://doc.rust-lang.org/cargo/reference/config.html>.
  • -q, --quiet β€” do not print cargo log messages. may also be specified with the term.quiet config 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 the Cargo.lock file is up-to-date. if the lock file is missing, or it needs to be updated, Cargo will exit with an error. the --frozen flag 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 to cargo begins with +, it will be interpreted as a rustup toolchain name (such as +stable or +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 of KEY=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 example cargo -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. run cargo -Z help for 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 the CARGO_HOME environment variable.
  • $CARGO_HOME/bin/ β€” binaries installed by cargo-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.toml in 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 πŸ”₯

  1. build a local package and all of its dependencies:
cargo build
  1. build a package with optimizations:
cargo build --release
  1. run tests for a cross-compiled target:
cargo test --target i686-unknown-linux-gnu
  1. create a new package that builds an executable:
cargo new foobar
  1. create a package in the current directory:
mkdir foo && cd foo
cargo init .
  1. 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 🧚

rustc(1), rustdoc(1)


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