Skip to content
Latchkey

rustup: Install Toolchains, Components, and Targets

rustup toolchain install adds a Rust channel, rustup component add adds tools like clippy, and rustup target add installs a cross-compile target.

rustup is the official Rust toolchain manager. In CI you typically install a channel, add the components a lint or format step needs, and add any target for cross builds or wasm.

What it does

rustup installs and switches Rust toolchains (stable, beta, nightly, or a pinned version), adds components such as clippy, rustfmt, and rust-src, and adds compilation targets like wasm32-unknown-unknown. A rust-toolchain.toml in the repo can pin all of this.

Common usage

bash
rustup toolchain install 1.78.0
rustup default 1.78.0
rustup component add clippy rustfmt
rustup target add wasm32-unknown-unknown
# or pin everything in rust-toolchain.toml and just run cargo build

Options

Command / flagWhat it does
rustup toolchain install <ch>Install a channel or pinned version
rustup default <ch>Set the default toolchain
rustup component add <c>Add clippy, rustfmt, rust-src, etc.
rustup target add <triple>Install a cross-compilation target
--profile minimalInstall fewer components (faster CI)
cargo +<toolchain> <cmd>Run cargo under a specific toolchain

In CI

Use --profile minimal and add only the components you need to keep installs fast. A rust-toolchain.toml is the most reproducible option because every runner resolves the same channel, components, and targets automatically. Cache ~/.cargo and ~/.rustup (or use a Rust caching action).

Common errors in CI

"error: toolchain 'X' is not installed" means you set an override without installing it; run rustup toolchain install X. "error: component 'clippy' for target '...' is unavailable for download" hits some nightly dates; pick a nightly that has it or pin stable. "error[E0463]: can't find crate for core" when cross-compiling means you forgot rustup target add <triple>.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →