rustup: Toolchains, Cross-Compilation & Channels Guide

Max WellsMax WellsFounder of Rustify

TL;DR: rustup is the official installer and version manager for Rust. It installs rustc, cargo, clippy, rustfmt, and the standard library in one command. Use rustup update to get the latest stable Rust. Use rustup target add for cross-compilation. Use rustup override set nightly to use nightly Rust in specific directories. rustup replaces the need for system package managers to install Rust; always install Rust through rustup, not apt/brew.


What Is rustup?

rustup installs and manages Rust toolchains; the compiler (rustc), package manager (cargo), and associated tools; and lets you switch between stable, beta, and nightly versions.

# Install rustup (and Rust) on Linux/macOS
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
 
# Verify installation
rustc --version    # rustc 1.xx.0 (...)
cargo --version    # cargo 1.xx.0 (...)
rustup --version   # rustup 1.xx.x (...)

What Are the Essential rustup Commands?

rustup update                    # update all installed toolchains to latest
rustup show                      # show installed toolchains and active one
rustup toolchain list            # list installed toolchains
 
# Install specific versions
rustup toolchain install stable
rustup toolchain install nightly
rustup toolchain install 1.75.0  # exact version
 
# Set default toolchain
rustup default stable
rustup default nightly
 
# Override toolchain for a specific directory (stored in rust-toolchain.toml)
rustup override set nightly
 
# Add components
rustup component add clippy
rustup component add rustfmt
rustup component add rust-analyzer  # LSP for IDEs
rustup component add rust-src       # source for std

How Do You Add Cross-Compilation Targets?

rustup target add downloads the standard library precompiled for a target platform so you can cross-compile.

# Add common targets
rustup target add wasm32-unknown-unknown        # WebAssembly
rustup target add x86_64-unknown-linux-musl    # Static Linux binary
rustup target add aarch64-apple-darwin          # Apple Silicon
rustup target add aarch64-unknown-linux-gnu     # ARM Linux (Raspberry Pi, etc.)
rustup target add x86_64-pc-windows-gnu        # Windows from Linux
 
# List all available targets
rustup target list
 
# Cross-compile
cargo build --target wasm32-unknown-unknown
cargo build --target x86_64-unknown-linux-musl

How Do You Pin a Rust Version With rust-toolchain.toml?

Add a rust-toolchain.toml file to your project to pin the Rust version for all contributors and CI.

# rust-toolchain.toml (in project root)
[toolchain]
channel = "stable"          # or "nightly", "1.75.0"
components = ["clippy", "rustfmt"]
targets = ["wasm32-unknown-unknown"]

rustup reads this file automatically; anyone running cargo build in the project gets the pinned toolchain installed silently.


What Is the Difference Between Stable, Beta, and Nightly?

ChannelRelease cadenceUse case
stableEvery 6 weeksProduction code; always recommended
beta6-week release candidateTesting upcoming stable features
nightlyEvery nightUnstable features (#![feature(...)])

Most projects should use stable. Use nightly only when a dependency or feature requires it; lock it in rust-toolchain.toml so the build is reproducible.


Frequently Asked Questions

Never. System package managers often ship outdated Rust versions and don't manage toolchains, components, or targets. Always install Rust via rustup; it's the official, supported method.

rustup update

This updates all installed toolchains. The Rust stable release ships every 6 weeks.

rustup self uninstall

This removes rustup, all toolchains, and all installed components cleanly.

rust-analyzer is the Rust Language Server; it powers IDE features (autocomplete, go-to-definition, inline errors) in VS Code, JetBrains, Neovim, etc. Install it with:

rustup component add rust-analyzer

Then install the corresponding IDE extension.

Run rustup default stable to set the default. This is usually a fresh install without a completed setup.


Sources


  • Cargo: The package manager installed alongside Rust via rustup
  • Clippy: Linter installed as a rustup component
  • WASM: WASM targets are added via rustup target add

Keep Reading

Ready to Land a $120k+ Rust Job in the US or Europe?