LinuxCommandLibrary

rustup-default

Set the default Rust toolchain

TLDR

Switch the default Rust toolchain (see rustup help toolchain for more information)

$ rustup default [toolchain]
copy

SYNOPSIS

rustup default
rustup default <toolchain>
rustup default --help

PARAMETERS

<toolchain>
    The name of the Rust toolchain to set as the new global default. This can be stable, beta, nightly, or a specific version (e.g., 1.70.0). The toolchain must already be installed or rustup will attempt to install it.

--help
    Displays help information for the rustup default command.

DESCRIPTION

rustup default is a subcommand of the rustup toolchain manager for Rust. Its primary function is to either display the currently active global default Rust toolchain or to set a new one.

When invoked without arguments, it shows which toolchain (e.g., stable, beta, nightly, or a specific version) is configured as the system-wide default. This toolchain will be used for Rust projects unless overridden by a project-specific configuration set via rustup override.

By specifying a toolchain name as an argument (e.g., rustup default stable or rustup default nightly), users can easily switch the default Rust compiler, standard library, and other associated tools. This is crucial for developers working on multiple projects or needing to test against different Rust versions. It ensures consistency across projects that don't have explicit overrides.

CAVEATS

The global default set by rustup default can be overridden by project-specific toolchain settings configured with rustup override set.
If the specified toolchain is not already installed, rustup will attempt to download and install it, requiring an active internet connection.
Ensure your PATH is correctly configured to include rustup's bin directory for commands to be accessible.

TOOLCHAIN SPECIFICATION

A <toolchain> argument typically refers to a release channel (stable, beta, nightly) or a specific version (e.g., 1.70.0, 1.70.0-x86_64-unknown-linux-gnu). It can also refer to custom-installed toolchains.

INTERACTION WITH OVERRIDES

While rustup default sets the global toolchain, local projects can specify their own toolchain using rustup override set. When rustup is invoked within such a project, the override takes precedence over the global default. To revert to the default, use rustup override unset.

HISTORY

rustup was introduced to provide a robust and user-friendly way to manage Rust toolchains, addressing the need for developers to easily switch between stable, beta, and nightly releases, as well as specific versions. The rustup default command is fundamental to this system, allowing users to establish a primary, system-wide Rust environment. Its development was driven by the Rust project's rapid release cycle and the need for flexible toolchain management.

SEE ALSO

Copied to clipboard