rustup is the official installer and version manager for the Rust toolchain (the compiler rustc, and Cargo). Cargo is Rust’s combined build tool and package manager: it compiles projects, runs tests, manages dependencies declared in Cargo.toml, and publishes packages (called crates) to the central registry, crates.io.
Installing with rustup
rustup is installed via a shell script from rust-lang.org, and manages everything else — including keeping multiple toolchain versions side by side and switching per-project.
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ rustc --version
rustc 1.96.0 (stable)
$ cargo --version
cargo 1.96.0Creating a project with Cargo
cargo new scaffolds a project with a Cargo.toml manifest and a src/main.rs entry point already wired up; cargo run compiles and runs in one step.
$ cargo new hello_rust
$ cd hello_rust
$ cargo run
Compiling hello_rust v0.1.0
Finished dev [unoptimized + debuginfo] target(s) in 0.42s
Running `target/debug/hello_rust`
Hello, world!Cargo.toml and adding dependencies
Dependencies (crates) are declared in Cargo.toml under [dependencies], following semantic versioning; cargo add can add one from the command line directly. Cargo.lock, generated automatically, pins the exact resolved versions for reproducible builds — comparable to go.sum or package-lock.json.
[package]
name = "hello_rust"
version = "0.1.0"
edition = "2024"
[dependencies]
serde = "1.0"
tokio = { version = "1", features = ["full"] }