Installing Rust
Rust is installed and managed through rustup — the official toolchain installer and version manager. It handles everything: compiler, build tools, and even switching between stable, beta, and nightly channels.
Why rustup? Rust ships a new stable release every 6 weeks. rustup makes it trivial to stay up-to-date and switch toolchains for cross-compilation or nightly features.
Prerequisites
Before installing, make sure you have:
- A terminal / command prompt
- Internet access
- A C linker (details per platform below)
Install by Platform
Linux / WSL
Linux & WSL
Run the following in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shThis downloads and runs the rustup-init script, which installs the latest stable Rust toolchain.
Linker required. Rust needs a system C linker. Install it for your distro:
# Ubuntu / Debian
sudo apt install build-essential
# Fedora / RHEL
sudo dnf install gcc
# Arch
sudo pacman -S base-develAfter installation, reload your shell to activate the ~/.cargo/bin path:
source "$HOME/.cargo/env"Or open a new terminal window.
Verify Installation
Open a new terminal window and run:
rustc --versionExpected output:
rustc 1.85.0 (4d91de4e4 2025-02-17)Also verify Cargo, Rust’s build tool and package manager:
cargo --versionExpected output:
cargo 1.85.0 (d73d2caf9 2024-12-31)command not found? Your shell hasn’t picked up the updated PATH. Close and re-open your terminal, or run:
source ~/.cargo/envOn Windows, check that %USERPROFILE%\.cargo\bin is in your system PATH.
What Gets Installed
All tools are placed in ~/.cargo/bin (Unix) or %USERPROFILE%\.cargo\bin (Windows).
- rustc
- cargo
- rustup
- rustfmt
- cargo-clippy
- rust-analyzer (optional)
| Tool | Purpose |
|---|---|
rustc | The Rust compiler — turns .rs source into binaries |
cargo | Build system + package manager — your main daily tool |
rustup | Toolchain manager — install channels, components, targets |
rustfmt | Auto-formatter — enforces community code style |
clippy | Advanced linter — catches common mistakes and anti-patterns |
Update Rust
Rust ships a new stable release every 6 weeks. Stay current with:
rustup updateTo update only the stable channel:
rustup update stableInstall Nightly (Optional)
The nightly channel gives you access to unstable/experimental features:
# Install nightly alongside stable
rustup toolchain install nightly
# Use nightly for a specific project only
rustup override set nightly
# Switch your global default
rustup default nightly
# Switch back to stable
rustup default stableNightly features can change or be removed at any time. Only use nightly in production if you know what you’re doing. Most projects should stay on stable.
Offline Documentation
rustup ships a local copy of The Rust Book and the standard library API docs:
# Open The Rust Programming Language book
rustup doc
# Open the standard library API reference
rustup doc --std
# Open the Cargo book
rustup doc --cargoUninstall
To completely remove Rust and rustup from your system:
rustup self uninstallThis removes all toolchains, tools, and cleans up PATH entries.
Next Steps
Create your first project
cargo new hello_world
cd hello_world
cargo runYou should see Hello, world! printed to the terminal.
Read The Rust Book
The best way to learn Rust is the official The Rust Programming Language book — or open it locally with rustup doc.
Set up your editor
Install rust-analyzer for your editor to get inline type hints, autocomplete, and live error checking:
- VS Code — search for
rust-analyzerin the Extensions panel - Neovim — use
mason.nvimor install via:LspInstall rust_analyzer
Explore Rust by Example
Rust by Example is a great companion to the book — every concept shown with runnable code.
Official references used in this guide: