- Home
- Package Managers
- Cargo
Cargo
What it is
Cargo is a command-line package manager and build tool for developing Rust packages. It downloads dependencies, compiles packages, helps make builds repeatable with lockfiles, and can create distributable packages or upload them to crates.io. Its commands cover compiling, checking, documenting, testing, running, packaging, installing, and publishing. The `cargo new` command creates a package, defaulting to a binary; use `--lib` to create a library. Cargo fetches packages from crates.io by default and also accepts dependencies from alternate registries, Git repositories, and local paths. Workspaces group packages under a shared lockfile and output directory. Package features can enable conditional compilation and optional dependencies. Cargo can work offline with locally cached data, and includes credential providers for registry authentication. The Rustup installer includes Cargo with the stable Rust release, with installation instructions for Windows, macOS, Linux, and other Unix-like systems. Cargo is open source under the MIT and Apache License, Version 2.0. Some documented features require a nightly toolchain and `-Z` flags.
For and against
For
- Free Rust package manager and build tool
- Supports crates.io, alternate registries, Git, and local paths
- Workspaces share a lockfile and output directory
- Offline mode can use locally cached data
Against
- Some features require nightly and `-Z` flags
- Used through a command-line interface
The verdict
Cargo covers package creation, dependency handling, builds, and publishing for Rust projects. Its offline and workspace support add options for working with cached dependencies and multiple related packages.
Who it suits
Cargo suits developers building Rust packages who want dependency management and build commands in one command-line tool. Its workspace and lockfile support may also suit projects that need coordinated packages and repeatable builds.
Plans and prices
Cargo
Free Rust package manager and build tool
Read 30 Sep 2026 · doc.rust-lang.org
On the record
- Alternate registries
- Cargo supports alternate registries configured through .cargo/config.toml and supports git and sparse registry protocols.doc.rust-lang.org · read 28 Sep 2026
- Build tool
- Cargo invokes rustc or another build tool with the correct parameters to build packages.doc.rust-lang.org · read 28 Sep 2026
- CI integrations
- The Cargo guide gives build and test examples for GitHub Actions, GitLab CI, builds.sr.ht, and CircleCI.doc.rust-lang.org · read 30 Sep 2026
- Command line
- Cargo is used through a command line interface.doc.rust-lang.org · read 30 Sep 2026
- Commands
- Cargo includes commands for compiling, checking, documenting, testing, running, packaging, installing, and publishing Rust packages.doc.rust-lang.org · read 28 Sep 2026
- Conditional compilation
- Cargo features express conditional compilation and optional dependencies and are enabled with command-line flags such as --features.doc.rust-lang.org · read 28 Sep 2026
- Conditional features
- Package features allow conditional compilation and optional dependencies, and can be enabled from the command line.doc.rust-lang.org · read 30 Sep 2026
- Default registry
- Cargo installs crates and fetches dependencies from a registry, with crates.io as the default registry.doc.rust-lang.org · read 28 Sep 2026
- Dependencies
- Cargo supports dependencies from crates.io, other registries, Git repositories, and local filesystem paths.doc.rust-lang.org · read 30 Sep 2026
- Dependency management
- Cargo downloads and builds package dependencies and helps ensure repeatable builds.doc.rust-lang.org · read 28 Sep 2026
- Dependency resolution
- Yesdoc.rust-lang.org · read 22 Sep 2026
- Extensibility
- Cargo supports new subcommands without modifying Cargo itself.github.com · read 28 Sep 2026
- Installation
- The documented rustup installer installs Cargo alongside the stable Rust release.doc.rust-lang.org · read 30 Sep 2026
- Intended users
- The Cargo Book presents Cargo as a tool for developing Rust packages.doc.rust-lang.org · read 30 Sep 2026
- Lockfile support
- Yesdoc.rust-lang.org · read 22 Sep 2026
- Nightly constraints
- Cargo documents some features as unstable and requiring a nightly toolchain and -Z flags.doc.rust-lang.org · read 30 Sep 2026
- Offline installation
- Yesdoc.rust-lang.org · read 22 Sep 2026
- Offline operation
- With net.offline set to true or the --offline option, Cargo avoids accessing the network and attempts to proceed with locally cached data.doc.rust-lang.org · read 28 Sep 2026