rustup
Manage Rust toolchains and versions
TLDR
Install the nightly toolchain for your system
Switch the default toolchain to nightly so that the cargo and rustc commands will use it
Use the nightly toolchain when inside the current project but leave global settings unchanged
Update all toolchains
List installed toolchains
Run cargo build with a certain toolchain
Open the local Rust documentation in the default web browser
SYNOPSIS
rustup [OPTIONS] <SUBCOMMAND> [ARGS...]
PARAMETERS
-h, --help
Prints help information for the main command or a specified subcommand.
--version
Prints rustup's version information.
-v, --verbose
Use verbose output. May be specified multiple times for more verbosity.
-q, --quiet
Silence all output. Overrides --verbose.
--color
Controls coloring of output.
DESCRIPTION
The rustup command is the official Rust toolchain installer and manager. It simplifies the process of installing Rust programming language, managing multiple Rust toolchains (e.g., stable, beta, nightly), and adding various components like `rust-src`, `rustfmt`, `clippy`, and different compilation targets.
It allows developers to easily switch between different Rust versions, which is crucial for testing compatibility, working on legacy projects, or utilizing experimental features. rustup also handles updates to the Rust toolchain, ensuring that users can keep their development environment current with minimal effort. By providing a unified way to manage Rust, it significantly enhances the developer experience, making Rust adoption and ongoing development much smoother.
CAVEATS
rustup requires an active internet connection for initial installation and updates, as it downloads toolchains and components from the internet.
While it manages toolchains effectively, it doesn't manage system-wide dependencies that Rust projects might need (e.g., OpenSSL, pkg-config).
Disk space can be a concern if many toolchains and targets are installed, as each can consume significant storage.
Cross-compilation setup, while aided by target installation, still requires understanding of environment variables and linker configurations.
KEY SUBCOMMANDS
rustup's primary functionality is accessed via its subcommands. Here are some of the most frequently used:
update [TOOLCHAIN]: Updates installed toolchains. If no toolchain is specified, all installed toolchains are updated.
install <TOOLCHAIN>: Installs a specific toolchain (e.g., `stable`, `beta`, `nightly`).
default <TOOLCHAIN>: Sets the default toolchain to use when no specific toolchain is active.
run <TOOLCHAIN> <COMMAND> [ARGS...]: Executes a command with a specific toolchain. Useful for testing against different Rust versions.
toolchain [SUBCOMMAND]: Manages installed toolchains (list, install, link, remove).
component [SUBCOMMAND]: Manages installed components (add, remove, list). Examples include `rust-src`, `rustfmt`, `clippy`.
target [SUBCOMMAND]: Manages installed compilation targets (add, remove, list). Essential for cross-compilation.
show: Shows the active and installed toolchains, along with their components and targets.
override [set|unset|list]: Manages directory-specific toolchain overrides, allowing different projects to use different Rust versions automatically.
TOOLCHAIN OVERRIDES
One of rustup's powerful features is its ability to set directory-specific toolchain overrides. This means you can have multiple Rust projects on your system, each configured to use a different Rust toolchain version. When you navigate into a project directory, rustup automatically switches to the configured toolchain for that directory, ensuring consistent builds and dependencies without manual switching. This is typically managed using `rustup override set
HISTORY
Initially, installing Rust involved directly downloading and running shell scripts. As Rust gained popularity and evolved rapidly, managing different versions and components became cumbersome. The rustup project was created to address this, becoming the official and recommended way to install and manage Rust toolchains around 2016-2017. Its development significantly streamlined the Rust ecosystem, making it easier for new users to get started and for experienced developers to manage complex project requirements across different Rust versions.