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
List installed toolchains
rustup toolchain list

# Display toolchains available on the machine.

Install nightly
rustup toolchain install nightly

# Add the nightly toolchain.

Install beta
rustup toolchain install beta

# Add the beta channel toolchain.

Set nightly as default
rustup default nightly

# Change the global default toolchain.

Pin a toolchain in one directory
rustup override set stable

# Create a directory override for the current folder.

Remove a directory override
rustup override unset

# Stop forcing a local toolchain override.

## rust-toolchain files
Pin toolchain in version-controlled config
[toolchain]
channel = "stable"
components = ["rustfmt", "clippy"]
targets = ["x86_64-unknown-linux-musl"]

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

Use stable once without changing defaults
cargo +stable test

# Run one command on the stable toolchain.

## Components
List components
rustup component list

# Show installed and available components for active toolchain.

Install rustfmt
rustup component add rustfmt

# Add the formatter component.

Install Clippy
rustup component add clippy

# Add the Clippy lint component.

Install rust-src
rustup component add rust-src

# Add standard library source code.

Open local Rust docs
rustup doc

# Launch the locally installed Rust documentation.

## Targets and cross-compilation
List available targets
rustup target list

# Show supported target triples.

Add a Linux musl target
rustup target add x86_64-unknown-linux-musl

# Install standard libraries for a cross target.

Add Apple Silicon target
rustup target add aarch64-apple-darwin

# Install support for macOS ARM builds.

Build for a target triple
cargo build --target x86_64-unknown-linux-musl

# Compile artifacts for a non-default platform.

Run is typically host-only
cargo build --target aarch64-apple-darwin

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

Recommended next

No recommendations yet.