Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
rustup is the only Rust install you should ever do — it's the toolchain manager, not the compiler. It lets you have stable, beta, and nightly side by side, switch the default per-shell, and pin a project to a specific toolchain via rust-toolchain.toml. The Rust release train ships every 6 weeks; understanding stable vs beta vs nightly (and that you almost always want stable) saves you from the classic 'I tried a feature gate at home and CI broke' fail.
Rustup is Rust's official toolchain multiplexer — it lets you install and switch between the stable, beta, and nightly compiler channels without touching your system PATH. Each project can pin a specific toolchain via a rust-toolchain.toml file, ensuring that cargo build always uses the exact compiler version the project was tested against. Understanding this separation means you can confidently experiment with nightly features in one project while shipping stable-only builds in another.
rustup show. Note the active toolchain — that's what cargo build will use.rustup toolchain install nightly. Try cargo +nightly --version to invoke it without changing default.rust-toolchain.toml in a fresh repo pinning to a specific version. CI will use exactly that version.rustup component list and note rustfmt, clippy, rust-analyzer — these are managed by rustup, not cargo.Use these three in order. Each builds on the one before.
In one paragraph, explain the difference between rustup, rustc, and cargo — and why every Rust developer interacts with all three.
Walk me through how `rustup` resolves toolchain selection: shell PATH, rust-toolchain.toml, `+stable` shorthand, default. Which wins?
When does a project legitimately need nightly Rust in production (vs developer-only tooling)? Pick a real use case (e.g. const generics, async traits pre-1.75) and the migration path.
# install (mac/linux):
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# verify:
$ rustc --version
rustc 1.78.0 (9b00956e5 2024-04-29)
$ cargo --version
cargo 1.78.0 (54d8815d0 2024-03-26)
# channels:
$ rustup toolchain list
stable-aarch64-apple-darwin (default)
$ rustup toolchain install nightly
$ rustup default stable
# pin a toolchain per-project:
$ cat rust-toolchain.toml
[toolchain]
channel = "1.78.0"
components = ["rustfmt", "clippy"]cargo run