CARGO(1)
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 thatrustcreported.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
cargo-add(1)β adds dependencies to aCargo.tomlmanifest file.cargo-generate-lockfile(1)β generatesCargo.lockfor a project.cargo-info(1)β shows info about a package in the registry. the default registry is crates.io.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-remove(1)β removes dependencies from aCargo.tomlmanifest file.cargo-tree(1)β shows a tree visualization of a dependency graph. it's giving family tree π¦cargo-update(1)β updates dependencies as recorded in the local lock file.cargo-vendor(1)β vendors all dependencies locally.cargo-verify-project(1)β checks the correctness of a 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.cargo-search(1)β searches packages in crates.io.cargo-uninstall(1)β removes a Rust binary.
π 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
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.--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).
π 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 theterm.verboseconfig 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 theterm.quietconfig 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 existingCargo.lockfile 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--lockedand--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+stableor+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 ofKEY=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, likecargo -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. runcargo -Z helpfor 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 theCARGO_HOMEenvironment variable.$CARGO_HOME/bin/β binaries installed bycargo-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.tomlin 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 β¨
- 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. (not me reading the issue tracker for fun π)
β¨ SEE ALSO β¨
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
- ubuntu jammy: cargo-1.83 1.83.0+dfsg0ubuntu2~bpo2-0ubuntu2.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.83 1.83.0+dfsg0ubuntu1~bpo2-0ubuntu0.24.04.1 Β· Apache-2.0 WITH LLVM exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms