CARGO(1)
π CARGO(1) π
okay bestie, welcome to the General Commands Manual, this is the CARGO(1) page and honestly? it's the main character of the whole Rust ecosystem. buckle up, we're reading a manpage and we're gonna enjoy it π
β¨ NAME β¨
cargo β The Rust package manager. that's it, that's the vibe. π
π¦ SYNOPSIS π¦
cargo [options] command [args]
cargo [options] --version
cargo [options] --list
cargo [options] --help
cargo [options] --explain code
like. it's giving "one binary, infinite possibilities". β¨
πΈ DESCRIPTION πΈ
okay so real talk: this program is a package manager and a build tool for the Rust language, and you can find it at <https://rust-lang.org>. it literally does your dependency wrangling, your compiling, your testing, your publishing. everything. iconic behaviour, no notes. π
π₯ COMMANDS π₯
π οΈ Build Commands
cargo-bench(1)β Execute benchmarks of a package. yes queen, time your code. β±οΈcargo-build(1)β Compile a package. the classic. the blueprint. πcargo-check(1)β Check a local package and all of its dependencies for errors. faster than a full build, less drama. β¨cargo-clean(1)β Remove artifacts that Cargo has generated in the past. spring cleaning but for your target dir. π§Ήcargo-doc(1)β Build a package's documentation. give the people docs. πcargo-fetch(1)β Fetch dependencies of a package from the network. go get 'em. πcargo-fix(1)β Automatically fix lint warnings reported byrustc. rustc complains, cargo says "i got u bestie". π©Ήcargo-run(1)β Run a binary or example of the local package. hit play. βΆοΈcargo-rustc(1)β Compile a package, and pass extra options to the compiler. for when you wanna talk directly to the compiler. π£οΈcargo-rustdoc(1)β Build a package's documentation, using specified custom flags. same energy, custom flags. π©cargo-test(1)β Execute unit and integration tests of a package. trust but verify. β
π 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. it's giving "we don't need that anymore". ποΈcargo-tree(1)β Display a tree visualization of a dependency graph. pretty little dependency forest π³cargo-update(1)β Update dependencies as recorded in the local lock file. πcargo-vendor(1)β Vendor all dependencies locally. bring them all home. π
π¦ Package Commands
cargo-init(1)β Create a new Cargo package in an existing directory. glow-up an existing folder β¨cargo-install(1)β Build and install a Rust binary. β¬οΈcargo-new(1)β Create a new Cargo package. baby's first crate πΌcargo-search(1)β Search packages incrates.io. π«cargo-uninstall(1)β Remove a Rust binary. bye bestie π
π Publishing Commands
cargo-login(1)β Save an API token from the registry locally. πcargo-logout(1)β Remove an API token from the registry locally. log off, log off πͺ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. the moment we've all been waiting for πcargo-yank(1)β Remove a pushed crate from the index. rip bozo π
π§ 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). like a translator for cryptic compiler yelling π«Ά
π 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 at <https://doc.rust-lang.org/cargo/reference/config.html>. (yes, very verbose is a real thing, it's a whole mood π£οΈ)-q,--quietβ Do not print cargo log messages. May also be specified with theterm.quietconfig value at <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 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 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. (fr fr, your CI will thank u) π§·
--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 at <https://doc.rust-lang.org/cargo/reference/config.html>. βοΈ
--frozenβ Equivalent to specifying both--lockedand--offline. the combo meal π
π 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 at <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 at <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 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 to Cargo. Runcargo -Z helpfor details. βοΈ
πΏ ENVIRONMENT πΏ
See the reference at <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. π
β EXIT STATUS β
0: Cargo succeeded. slay π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 at <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 at <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
like. the range. the versatility. obsessed. π
π BUGS π
See <https://github.com/rust-lang/cargo/issues> for issues. found a bug? tell the maintainers, they're nice, no cap. π«Ά
π SEE ALSO π
and that's the whole page bestie!! π this was the CARGO(1) page from the General Commands Manual β the last line just says CARGO(1) again, because the footer is literally just the page name, and honestly? iconic of it to be that self-confident. go forth and cargo build something beautiful. ππ¦β¨
π¦ where this page comes from
- ubuntu resolute: cargo-1.92 1.92.0+dfsg-0ubuntu2 Β· 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