Cargo
doc.rust-lang.org
What it is
Cargo is the free package manager and build tool for Rust, used through a command-line interface. It downloads dependencies, builds packages, and supports repeatable builds with lockfiles. Developers can compile, check, document, test, run, package, install, and publish Rust projects. The `cargo new` command creates a package, defaulting to a binary; adding `--lib` creates a library. Cargo uses crates.io by default and also handles alternate registries, Git dependencies, and local paths. Workspaces allow multiple packages to share a lockfile and output directory. Package features can enable conditional compilation and optional dependencies. In offline mode, Cargo avoids network access and attempts to use cached data. It supports authentication options for registries and new subcommands without modifying Cargo itself. Rustup installs Cargo with the stable Rust release, and installation instructions cover Windows, macOS, Linux, and other Unix-like systems. Cargo is open source under the MIT and Apache License, Version 2.0. Some documented capabilities remain unstable and require a nightly toolchain and `-Z` flags.
Spec sheet
- What it does
- Cargo downloads package dependencies, compiles packages, creates distributable packages, and can upload them to the crates.io registry.Read 30 Sep 2026 · doc.rust-lang.org
- Purpose
- Cargo is the Rust package manager.Read 28 Sep 2026 · doc.rust-lang.org
- Intended users
- The Cargo Book presents Cargo as a tool for developing Rust packages.Read 30 Sep 2026 · doc.rust-lang.org
- Free plan
- YesRead 22 Sep 2026 · doc.rust-lang.org
- Support
- Cargo asks users to report bugs through its GitHub issue tracker.Read 28 Sep 2026 · github.com
- Alternate registries
- Cargo supports alternate registries configured through .cargo/config.toml and supports git and sparse registry protocols.Read 28 Sep 2026 · doc.rust-lang.org
- Build tool
- Cargo invokes rustc or another build tool with the correct parameters to build packages.Read 28 Sep 2026 · doc.rust-lang.org
- CI integrations
- The Cargo guide gives build and test examples for GitHub Actions, GitLab CI, builds.sr.ht, and CircleCI.Read 30 Sep 2026 · doc.rust-lang.org
- Command line
- Cargo is used through a command line interface.Read 30 Sep 2026 · doc.rust-lang.org
- Commands
- Cargo includes commands for compiling, checking, documenting, testing, running, packaging, installing, and publishing Rust packages.Read 28 Sep 2026 · doc.rust-lang.org
- Conditional compilation
- Cargo features express conditional compilation and optional dependencies and are enabled with command-line flags such as --features.Read 28 Sep 2026 · doc.rust-lang.org
- Conditional features
- Package features allow conditional compilation and optional dependencies, and can be enabled from the command line.Read 30 Sep 2026 · doc.rust-lang.org
- Default registry
- Cargo installs crates and fetches dependencies from a registry, with crates.io as the default registry.Read 28 Sep 2026 · doc.rust-lang.org
- Dependencies
- Cargo supports dependencies from crates.io, other registries, Git repositories, and local filesystem paths.Read 30 Sep 2026 · doc.rust-lang.org
- Dependency management
- Cargo downloads and builds package dependencies and helps ensure repeatable builds.Read 28 Sep 2026 · doc.rust-lang.org
- Dependency resolution
- YesRead 22 Sep 2026 · doc.rust-lang.org
- Extensibility
- Cargo supports new subcommands without modifying Cargo itself.Read 28 Sep 2026 · github.com
- Installation
- The documented rustup installer installs Cargo alongside the stable Rust release.Read 30 Sep 2026 · doc.rust-lang.org
- Lockfile support
- YesRead 22 Sep 2026 · doc.rust-lang.org
- Nightly constraints
- Cargo documents some features as unstable and requiring a nightly toolchain and -Z flags.Read 30 Sep 2026 · doc.rust-lang.org
- Offline installation
- YesRead 22 Sep 2026 · doc.rust-lang.org
- 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.Read 28 Sep 2026 · doc.rust-lang.org
- Package creation
- The cargo new command creates a package and defaults to creating a binary program; --lib creates a library.Read 28 Sep 2026 · doc.rust-lang.org
- Package formats
- Rust crates; crates.io packages; alternate registry packages; Git dependencies; local path dependenciesRead 22 Sep 2026 · doc.rust-lang.org
- Package yanking
- Cargo can mark a published crate version yanked so new dependency resolution avoids it while existing lockfiles continue to work.Read 30 Sep 2026 · doc.rust-lang.org
- Private registry auth
- YesRead 22 Sep 2026 · doc.rust-lang.org
- Registry authentication
- Cargo includes credential providers that can store tokens in Windows Credential Manager, macOS Keychain, or libsecret; its cargo:token provider stores tokens as unencrypted text.Read 30 Sep 2026 · doc.rust-lang.org
- Source and licensing
- Cargo is open source and is primarily distributed under both the MIT license and the Apache License, Version 2.0.Read 28 Sep 2026 · github.com
- Support and documentation
- The Cargo Book includes a guide, command reference, FAQ, glossary, Git authentication appendix, and changelog.Read 30 Sep 2026 · doc.rust-lang.org
- Supported install systems
- The installation instructions provide steps for Linux, macOS, and Windows.Read 30 Sep 2026 · doc.rust-lang.org
- Supported platforms
- Windows; macOS; Linux; other Unix-like systemsRead 22 Sep 2026 · doc.rust-lang.org
- Supported systems
- Rustup installation instructions cover Windows, macOS, Linux, and other Unix-like systems, and Cargo is included in the Rust toolchain.Read 28 Sep 2026 · rust-lang.org
- Workspace support
- YesRead 22 Sep 2026 · doc.rust-lang.org
- Workspaces
- Cargo workspaces let related packages share dependency resolution, a lockfile, and an output directory.Read 30 Sep 2026 · doc.rust-lang.org
Plans and prices
Strong points and limits
Strong points
- Free package manager included with the Rust toolchain.
- Supports crates.io, alternate registries, Git, and local paths.
- Workspaces share a lockfile and output directory.
- Offline mode can use locally cached data.
Limits
- Some features require a nightly toolchain and `-Z` flags.
- Cargo is operated through a command-line interface.
Who it suits
Cargo is for developers building Rust packages who want dependency management, builds, tests, and publishing from the command line.
Cargo in depth
Read the full write-up
Cargo is Rust’s command-line package manager and build tool, suited to developers who want one workflow for dependencies, compilation, testing, and publishing. It is the sensible default for Rust projects; look elsewhere when you need a language-agnostic manager or cannot accept nightly-only capabilities.
Overview
Cargo handles the full Rust package lifecycle. It downloads dependencies, invokes rustc or another build tool with appropriate parameters, and provides commands for compiling, checking, documenting, testing, running, packaging, installing, and publishing packages. cargo new creates a binary package by default, while --lib starts a library package.
Dependency sources include crates.io, alternate registries, Git repositories, and local filesystem paths. Lockfiles support repeatable builds, and workspaces let multiple packages share a Cargo.lock file and output directory. The limitation is deliberate: Cargo is for Rust packages, not a general dependency system across languages.
Key features
Dependencies and registries
Crates.io is the default registry, with alternate registries configured through .cargo/config.toml and usable via Git or sparse protocols. Private-registry authentication is built in. Credential providers can place tokens in Windows Credential Manager, macOS Keychain, or libsecret; the cargo:token provider stores tokens as unencrypted text, so credential choice matters.
Builds, features, and workspaces
Cargo passes the correct build parameters to the compiler and supports package features for conditional compilation and optional dependencies. Teams can enable those features from the command line with flags such as --features. Workspaces are valuable for monorepos because related packages share dependency locking and build output, reducing duplicated management.
Offline and publishing workflows
Setting net.offline to true or using --offline prevents network access and attempts to build from cached data. That is useful for restricted networks and repeatable automation, but it cannot supply packages that are not already cached. Cargo can create distributable packages, upload them to crates.io, and yank a published version so new resolution avoids it while existing lockfiles continue using it.
Automation and extensibility
Guidance covers build and test jobs for GitHub Actions, GitLab CI, builds.sr.ht, and CircleCI. New subcommands can extend Cargo without changing the core program. Some documented capabilities are unstable: they require a nightly toolchain and -Z flags, which is a material constraint for teams committed to stable Rust.
Pricing
Cargo costs free on its free plan. There is no trial because the plan is free, and no seats, quotas, renewal charges, or paid tiers apply. Every Rust developer can use the complete package manager and build-tool workflow without a subscription. Cargo is open source, primarily under the MIT and Apache License 2.0 licenses.
Platforms
Cargo is included with the Rust toolchain installed through rustup. Installation instructions cover Windows, macOS, and Linux, with support also extending to other Unix-like systems. It runs through a command-line interface, so suitability depends on comfort with terminal-based development rather than a graphical workflow.
Who it's for
Cargo is for Rust developers building binaries, libraries, or multi-package workspaces, including teams that need private registries, lockfile-based reproducibility, offline operation, and CI examples. It is particularly strong when dependency acquisition, compilation, testing, packaging, and crates.io publishing should share one tool. Choose another manager for projects whose primary ecosystem is JavaScript, Python, C/C++, or another language.
Pros and cons
Pro: Covers dependency resolution, builds, checks, tests, documentation, packaging, installation, and publishing in one Rust-native workflow.
Pro: Lockfiles, workspaces, alternate registries, Git and path dependencies, and offline mode support controlled and repeatable builds.
Pro: Private-registry credential providers integrate with major desktop secret stores.
Con: Its scope is limited to Rust packages and a command-line workflow.
Con: Unstable features require nightly Rust and -Z flags, complicating stable-toolchain policies.
Con: The cargo:token credential provider keeps tokens unencrypted.
Alternatives
Package Managers is the broader category overview for comparing ecosystems. Choose npm for JavaScript and Node.js projects, with a free tier for public package authors and paid plans beyond that use case. Choose uv for a free, open-source Python package workflow. Gradle is the better fit when you need a general build system spanning API, Linux, macOS, and Windows. Yarn and pnpm are free JavaScript package-manager alternatives. Conan targets C and C++ package and binary management. pip is the straightforward free choice for Python packages. vcpkg is a free, open-source option for C and C++ across desktop and mobile platforms.
Verdict
Cargo is the right choice for Rust developers who want a free, integrated command-line system for dependencies, reproducible builds, testing, workspaces, and publishing. Its main reason to look elsewhere is equally clear: it is Rust-specific, and its unstable features demand nightly Rust rather than a stable-only toolchain.
Verdict
Cargo covers package dependencies, builds, testing, and publishing for Rust projects across major desktop systems. Check whether any needed capabilities are among the documented unstable features.
Where Specifiction places it
- Package Managers#6 of 938.8