Rust CLI rustup, Toolchains, Components, and Targets

Manage Rust toolchains with rustup, switch channels, install components, and add cross-compilation targets.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Toolchains

Install, list, and switch between stable, beta, nightly, and custom toolchains.

List installed toolchains

Display toolchains available on the machine.

bashANYrustuptoolchainlist
bash
rustup toolchain list
Notes

Shows installed toolchains and which one is active.

Install nightly

Add the nightly toolchain.

bashANYrustuptoolchaininstall
bash
rustup toolchain install nightly
Notes

Nightly is commonly used for unstable features or tooling experiments.

Install beta

Add the beta channel toolchain.

bashANYrustuptoolchainbeta
bash
rustup toolchain install beta
Notes

Beta helps verify compatibility before stable releases.

Set nightly as default

Change the global default toolchain.

bashANYrustupdefaultnightly
bash
rustup default nightly
Notes

Applies outside directories that have overrides or rust-toolchain files.

Pin a toolchain in one directory

Create a directory override for the current folder.

bashANYrustupoverride
bash
rustup override set stable
Notes

Directory overrides let a project use a different toolchain than global default.

Remove a directory override

Stop forcing a local toolchain override.

bashANYrustupoverride
bash
rustup override unset
Notes

Use this when a project no longer needs a local override.

rust-toolchain files

Commit toolchain choices to the repository.

Pin toolchain in version-controlled config

Check in a `rust-toolchain.toml` file.

tomlANYrustuptoolchaintoml
toml
[toolchain]
channel = "stable"
components = ["rustfmt", "clippy"]
targets = ["x86_64-unknown-linux-musl"]
Notes

A rust-toolchain file can pin channel, components, and targets for a repo.

Use stable once without changing defaults

Run one command on the stable toolchain.

bashANYcargorustuptoolchain
bash
cargo +stable test
Notes

The `+toolchain` shorthand overrides the toolchain for that invocation.

Components

Install rustfmt, Clippy, docs, and source code components.

List components

Show installed and available components for active toolchain.

bashANYrustupcomponentlist
bash
rustup component list
Notes

Useful for seeing whether rustfmt or clippy is already available.

Install rustfmt

Add the formatter component.

bashANYrustupcomponentrustfmt
bash
rustup component add rustfmt
Notes

Required before running `cargo fmt` on some toolchains.

Install Clippy

Add the Clippy lint component.

bashANYrustupcomponentclippy
bash
rustup component add clippy
Notes

Required before running `cargo clippy`.

Install rust-src

Add standard library source code.

bashANYrustupcomponentrust-src
bash
rustup component add rust-src
Notes

Needed by some IDEs, tools, and advanced workflows.

Open local Rust docs

Launch the locally installed Rust documentation.

bashANYrustupdocs
bash
rustup doc
Notes

Convenient for offline browsing of docs.

Targets and cross-compilation

Add platform targets and build for different target triples.

List available targets

Show supported target triples.

bashANYrustuptargetlist
bash
rustup target list
Notes

Includes installed status for each target.

Add a Linux musl target

Install standard libraries for a cross target.

bashANYrustuptargetmusl
bash
rustup target add x86_64-unknown-linux-musl
Notes

You must usually add the target before cross-compiling to it.

Add Apple Silicon target

Install support for macOS ARM builds.

bashANYrustuptargetdarwin
bash
rustup target add aarch64-apple-darwin
Notes

Useful when cross-building or producing release artifacts for macOS ARM.

Build for a target triple

Compile artifacts for a non-default platform.

bashANYcargobuildtarget
bash
cargo build --target x86_64-unknown-linux-musl
Notes

Target-specific artifacts are stored under `target/<triple>/...`.

Run is typically host-only

Build target-specific binaries for packaging instead of running them locally.

bashANYcargotargetcross
bash
cargo build --target aarch64-apple-darwin
Notes

Cross-target binaries usually cannot be executed directly on the host unless compatible.

Recommended next

No recommendations yet.