rustup & Toolchain Management
rustup installs and switches Rust toolchains, components (clippy, rustfmt), and cross-compilation targets. It is the supported way to manage Rust on developer machines and CI.
Recipe
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup default stable
rustup toolchain install 1.97.0
rustup component add rustfmt clippy rust-analyzer
rustup target add wasm32-unknown-unknownWhen to reach for this:
- Onboarding new developers
- Pinning MSRV across team
- Adding ARM or musl targets for release builds
Working Example
# rust-toolchain.toml (repo root)
[toolchain]
channel = "1.97.0"
components = ["rustfmt", "clippy"]
targets = ["x86_64-unknown-linux-gnu"]cd my-repo
rustc --version # 1.97.0 via override
cargo clippyWhat this demonstrates:
rust-toolchain.tomlauto-selects toolchain in directory- Components travel with pinned channel
- CI should use same pin via
dtolnay/rust-toolchain
Deep Dive
Channels
| Channel | Use |
|---|---|
stable | Production MSRV alignment |
beta | Preview upcoming stable |
nightly | Miri, unstable features |
Profiles
rustup set profile minimal on CI agents; default on dev laptops includes rust-docs.
Gotchas
- Distro
apt install rustc- ancient version. Fix: rustup only; remove apt rust. - Forgot component -
clippynot found. Fix:rustup component add clippy. - Override confusion - global stable vs project 1.97. Fix: trust
rust-toolchain.toml. - WSL path mixing - Windows rustup vs Linux rustup. Fix: one environment per workflow.
- Disk usage - many toolchains fill disk. Fix:
rustup toolchain listand prune old.
Alternatives
| Alternative | Use When | Don't Use When |
|---|---|---|
| Nix flake | Reproducible dev shells | Team has no Nix |
| Docker dev image | Identical CI/dev | Native IDE speed preferred |
asdf rust plugin | Polyglot version managers | Standard rustup suffices |
FAQs
How to uninstall old toolchains?
rustup toolchain uninstall 1.75.0
rust-analyzer wrong version?
Ensure VS Code uses rustup rust-analyzer component, not standalone binary mismatch.
Multiple projects, different MSRV?
Each repo's rust-toolchain.toml applies on cd.
Related
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.