Cargo is Rust's official build tool and package manager, developed and maintained by the Rust project as part of the core toolchain. It's tied for #18 among the most-used developer tools, reported in roughly 14.4% of developer surveys. Every Rust installation bundles it, and it's widely regarded as one of the best-designed dependency systems in any language โ handling compiling, testing, documentation generation, and publishing to the crates.io registry from a single command-line tool.
Every Cargo project is described by a Cargo.toml manifest file, where dependencies are declared by name and version.
cargo new myproject
# creates myproject/Cargo.toml and myproject/src/main.rs
# Cargo.toml
[package]
name = "myproject"
version = "0.1.0"
edition = "2021"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1", features = ["full"] }
Cargo comes bundled with Rust โ install both together via rustup, then use Cargo to build and run any project.
# install Rust + Cargo (Linux/macOS)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# build and run the current project
cargo build
cargo run