CARGO(1)

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

CARGO(1) β€” the Rust package manager, bestie edition πŸ’…

okay so. this is cargo(1) from the General Commands Manual, and she's the moment. everything you need is right here, i promise, no gatekeeping. 🫢


✨ NAME ✨

cargo β€” the Rust package manager. that's her. that's the whole vibe. πŸ‘‘


✨ SYNOPSIS ✨

cargo [options] command [args]
cargo [options] --version
cargo [options] --list
cargo [options] --help
cargo [options] --explain code

✨ DESCRIPTION ✨

so basically this program is a package manager and a build tool for the Rust language, and you can find Rust at <https://rust-lang.org>. she does it all, fr fr. 🌸


✨ COMMANDS ✨

🌈 Build Commands

  • cargo-bench(1) β€” runs benchmarks for a package. numbers go brrr.
  • cargo-build(1) β€” compiles a package.
  • cargo-check(1) β€” checks a local package and all of its dependencies for errors.
  • cargo-clean(1) β€” deletes artifacts that Cargo made in the past. (yes she's cleaning up her room, growth ✨)
  • cargo-doc(1) β€” builds a package's documentation.
  • cargo-fetch(1) β€” fetches a package's dependencies from the network.
  • cargo-fix(1) β€” automatically fixes lint warnings that rustc reported.
  • cargo-run(1) β€” runs a binary or an example of the local package.
  • cargo-rustc(1) β€” compiles a package and passes extra options to the compiler.
  • cargo-rustdoc(1) β€” builds a package's documentation using the custom flags you specify.
  • cargo-test(1) β€” runs a package's unit and integration tests.

🌈 Manifest Commands

🌈 Package Commands

🌈 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. main character moment πŸŽ€
  • cargo-yank(1) β€” removes a pushed crate from the index.

🌈 General Commands


✨ OPTIONS ✨

πŸ’– Special Options

  • -V, --version β€” prints version info and exits. if you use it with --verbose, it prints extra information.
  • --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).

πŸ’– Display Options

  • -v, --verbose β€” use verbose output. you can specify it twice for "very verbose" output, which includes extra output like dependency warnings and build script output. it can also be set with the term.verbose config value at <https://doc.rust-lang.org/cargo/reference/config.html>.
  • -q, --quiet β€” don't print cargo log messages. it can also be set with the term.quiet config value at <https://doc.rust-lang.org/cargo/reference/config.html>.
  • --color when β€” controls when colored output is used. valid values are:
    • auto (default): automatically detects whether color support is available on the terminal.
    • always: always displays colors.
    • never: never displays colors.

it can also be set with the term.color config value at <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 existing Cargo.lock file was originally generated. Cargo will exit with an error when either of these scenarios comes up:
    • the lock file is missing.
    • Cargo attempted to change the lock file because of a different dependency resolution.

you can use it in environments where you want deterministic builds, like in CI pipelines.

  • --offline β€” stops 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 isn't available. with this flag, Cargo will try to proceed without the network if it can.
⚠️ beware, bestie: this may result in a different dependency resolution than online mode. Cargo restricts 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.

it can also be set with the net.offline config value at <https://doc.rust-lang.org/cargo/reference/config.html>.

  • --frozen β€” equivalent to specifying both --locked and --offline.

πŸ’– Common Options

  • +toolchain β€” if Cargo was installed with rustup, and the first argument to cargo begins with +, it gets interpreted as a rustup toolchain name (like +stable or +nightly). see the rustup documentation at <https://rust-lang.github.io/rustup/overrides.html> for more info on 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 given as a path to an extra configuration file. you can specify this flag multiple times. see the command-line overrides section at <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides> for more info.
  • -C PATH β€” changes the current working directory before running any specified operations. this affects things like where cargo looks by default for the project manifest (Cargo.toml), and the directories searched for discovering .cargo/config.toml, for example. this option must appear before the command name, like cargo -C path/to/my-project build.
⚠️ this option is only available on the nightly channel at <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and requires the -Z unstable-options flag to enable (see #10098 at <https://github.com/rust-lang/cargo/issues/10098>).
  • -h, --help β€” prints help information.
  • -Z flag β€” unstable (nightly-only) flags for Cargo. run cargo -Z help for details.

✨ ENVIRONMENT ✨

see the reference at <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for the 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 the CARGO_HOME environment variable.
  • $CARGO_HOME/bin/ β€” binaries installed by cargo-install(1) live here. if you're using rustup at <https://rust-lang.github.io/rustup/>, the executables distributed with Rust are also located here.
  • $CARGO_HOME/config.toml β€” the global configuration file. see the reference at <https://doc.rust-lang.org/cargo/reference/config.html> for more info 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 get 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 ✨

  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. (not me reading the issue tracker for fun πŸ™ˆ)


✨ SEE ALSO ✨

rustc(1), rustdoc(1)


and that's the whole page, bestie!! this was CARGO(1) from the General Commands Manual β€” like, the actual manual page, footer and all, dated and versioned as CARGO(1) πŸ’– she ate, no crumbs, periodt. now go build something iconic. βœ¨πŸ¦‹πŸ‘‘

πŸ“¦ where this page comes from