Installing Rust
The recommended way to install Rust is through rustup, the official Rust toolchain manager.
Linux and macOS
Open a terminal and run:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Follow the on-screen instructions. The default installation is recommended for most users.
After installation, restart your terminal or run:
source $HOME/.cargo/env
Verify Installation
rustc --version
cargo --version
You should see output like:
rustc 1.75.0 (82e1608df 2023-12-21)
cargo 1.75.0 (1d8b05cdd 2023-11-20)
Windows
Option 1: Using rustup-init.exe (Recommended)
- Download rustup-init.exe
- Run the installer
- Follow the on-screen instructions
You’ll need the Visual Studio C++ Build Tools. The installer will guide you through this.
Option 2: Visual Studio Build Tools
If you don’t have Visual Studio:
- Download Visual Studio Build Tools
- Install “Desktop development with C++”
- Then run rustup-init.exe
Verify on Windows
Open Command Prompt or PowerShell:
rustc --version
cargo --version
Understanding the Toolchain
After installation, you have:
| Tool | Purpose |
|---|---|
rustc |
The Rust compiler |
cargo |
Package manager and build tool |
rustup |
Toolchain manager |
rustfmt |
Code formatter |
clippy |
Linter (install separately) |
Toolchain Channels
Rust has three release channels:
graph LR
Nightly[Nightly] -->|6 weeks| Beta[Beta]
Beta -->|6 weeks| Stable[Stable]
- Stable: Recommended for most use cases (default)
- Beta: Next stable release, for testing
- Nightly: Latest features, may break
Switching Channels
# Install nightly
rustup install nightly
# Use nightly for current project
rustup override set nightly
# Use nightly globally
rustup default nightly
# Return to stable
rustup default stable
Adding Components
Install additional tools:
# Code formatter
rustup component add rustfmt
# Linter
rustup component add clippy
# Language server (for IDEs)
rustup component add rust-analyzer
Cross-Compilation Targets
Add compilation targets for other platforms:
# List available targets
rustup target list
# Add WebAssembly target
rustup target add wasm32-unknown-unknown
# Add ARM target
rustup target add aarch64-unknown-linux-gnu
Updating Rust
Keep your toolchain current:
rustup update
Uninstalling Rust
If you ever need to uninstall:
rustup self uninstall
Troubleshooting
PATH Issues
If rustc isn’t found after installation:
Linux/macOS:
export PATH="$HOME/.cargo/bin:$PATH"
# Add to ~/.bashrc or ~/.zshrc for permanent fix
Windows: Restart your terminal or computer.
Permission Denied (Linux/macOS)
Don’t use sudo with rustup. If you have permission issues:
# Fix ownership
sudo chown -R $(whoami) ~/.cargo ~/.rustup
Linker Errors (Linux)
Install build essentials:
# Ubuntu/Debian
sudo apt install build-essential
# Fedora
sudo dnf install gcc
# Arch
sudo pacman -S base-devel
Next Steps
With Rust installed, let’s set up your IDE for the best development experience.