rustup-component
Install, update, or uninstall Rust components
TLDR
Add a component to a toolchain
Remove a component from a toolchain
List installed and available components for a toolchain
List installed components for a toolchain
SYNOPSIS
rustup component <subcommand> [options]
rustup component add <component> [--toolchain <toolchain>]
rustup component remove <component> [--toolchain <toolchain>]
rustup component list [--toolchain <toolchain>] [--installed]
PARAMETERS
add
Installs a specific component to the active or specified toolchain.
remove
Uninstalls a specific component from the active or specified toolchain.
list
Lists all available components or those installed for a toolchain. By default, it shows all available components.
<component>
The exact name of the component to add or remove (e.g., rustc, cargo, rust-docs, clippy, rustfmt, rust-analyzer, llvm-tools-preview). These names are case-sensitive.
--toolchain <toolchain>
Specifies the toolchain (e.g., stable, beta, nightly-x86_64-unknown-linux-gnu) to which the operation should apply. If omitted, the default toolchain is used.
--installed
Used exclusively with the 'list' subcommand, this flag filters the output to show only the components that are currently installed for the specified (or default) toolchain.
DESCRIPTION
The rustup-component command is a crucial subcommand of rustup, the official Rust toolchain installer. It provides fine-grained control over the individual pieces that make up a Rust development environment.
Users can leverage rustup component to add, remove, or list specific components (such as rustc, cargo, rust-std, rust-docs, clippy, rustfmt, or rust-analyzer) for any installed Rust toolchain. This modularity is vital for managing disk space, tailoring a Rust installation to specific development needs, or ensuring particular tools are available for a given Rust version or target platform.
It enables developers to maintain a lean installation or a full-featured one, depending on their project requirements.
CAVEATS
- Requires rustup to be installed and properly configured on your system.
- Operations are specific to a single toolchain. Components installed for one toolchain (e.g., stable) are not automatically available for others (e.g., nightly).
- Some core components like rustc and cargo are fundamental to a toolchain's operation and might be installed by default or even be non-removable.
- The availability of certain components can vary by toolchain release channel (stable, beta, nightly) and target triplet (e.g., x86_64-unknown-linux-gnu).
WHAT IS A RUST COMPONENT?
In the context of rustup, a 'component' refers to a discrete, installable part of the Rust toolchain. These components are designed to be managed independently, allowing users to pick and choose which parts of the Rust development environment they need. Common examples include:
- rustc: The Rust compiler.
- cargo: The Rust package manager and build tool.
- rust-std: The standard library for a specific target architecture.
- rust-docs: Offline copies of the official Rust documentation.
- clippy: A collection of lints to catch common mistakes and improve your Rust code.
- rustfmt: A tool for automatically formatting Rust code according to community style guidelines.
- rust-analyzer: The Language Server Protocol (LSP) server for Rust, often used by IDEs for features like code completion, go-to-definition, and refactoring.
- llvm-tools-preview: A collection of LLVM tools, sometimes required for advanced Rust development.
HISTORY
The modular concept of managing Rust toolchain components was integral to rustup from its early development. As the Rust ecosystem expanded and new tools emerged (like clippy, rustfmt, and rust-analyzer), the rustup component command became increasingly vital. It empowered users to customize their Rust installations, optimizing disk space and ensuring that only the necessary development tools were present for their specific projects and toolchain versions. This design choice reflects Rust's commitment to flexibility and user control over their development environment.
SEE ALSO
rustup(1), rustup-toolchain(1), rustup-update(1)