Rustup - Install and Manage Rust Toolchains

Install and manage Rust toolchains with ease using Rustup. This comprehensive guide covers installation, updates, toolchain management, and troubleshooting.

Rustup

Rustup is the official toolchain installer and version manager for the Rust programming language. It simplifies the process of installing, updating, and managing different versions of the Rust compiler and related tools.

Installing Rust

To install the stable Rust toolchain, simply run the following command:

rustup install stable

Updating Rust

Keep your Rust toolchains up-to-date by running:

rustup update

Managing Toolchains

List installed toolchains:

rustup toolchain list

Set the default toolchain:

rustup default stable

Add a target for cross-compilation (e.g., for WebAssembly):

rustup target add wasm32-unknown-unknown

Remove a toolchain:

rustup toolchain remove nightly

Run a command with a specific toolchain:

rustup run nightly cargo build

Uninstalling Rustup

To completely uninstall rustup and all associated tools:

rustup self uninstall

Troubleshooting

Use the following command to diagnose potential environment issues:

rustup doctor

Adding Components

Add additional components to a toolchain (e.g., rustfmt):

rustup component add rustfmt

For more detailed information and advanced usage, refer to the official Rustup documentation.