Scripts2026年5月18日·1 分钟阅读

rustup — The Official Rust Toolchain Installer and Manager

rustup is the official tool for installing and managing Rust toolchains. It handles stable, beta, and nightly releases, cross-compilation targets, and components like clippy, rustfmt, and rust-analyzer across all supported platforms.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
rustup Toolchain Manager
通用 CLI 安装命令
npx tokrepo install 22fbee2a-52b6-11f1-9bc6-00163e2b0d79

Introduction

rustup is the official installer and version manager for the Rust programming language. It manages multiple Rust toolchain versions side by side, handles cross-compilation targets, and installs companion tools like clippy and rustfmt. It is the recommended way to install Rust on any platform.

What rustup Does

  • Installs and updates stable, beta, and nightly Rust toolchains with a single command
  • Manages cross-compilation targets like WebAssembly, ARM, and RISC-V
  • Installs and updates components including clippy, rustfmt, rust-src, and rust-analyzer
  • Supports per-directory toolchain overrides via rust-toolchain.toml files
  • Provides proxy binaries that route rustc, cargo, and other tools to the active toolchain

Architecture Overview

rustup installs itself as a set of proxy binaries (rustc, cargo, rustup) that detect which toolchain to use based on directory overrides, environment variables, or the default setting. When invoked, the proxy resolves the correct toolchain path and executes the real binary. Toolchains are downloaded as compressed archives from Rust's official distribution servers and stored in ~/.rustup/toolchains/. Each toolchain is self-contained with its own compiler, standard library, and installed components.

Self-Hosting & Configuration

  • Install on Unix with the one-liner: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • On Windows, download and run rustup-init.exe from https://rustup.rs
  • Set a project-specific toolchain by creating a rust-toolchain.toml with [toolchain] channel = "nightly"
  • Configure the default toolchain with rustup default stable or rustup default nightly-2026-01-15
  • Set RUSTUP_HOME and CARGO_HOME environment variables to customize installation directories

Key Features

  • Seamless switching between stable, beta, nightly, and dated nightly toolchains
  • Cross-compilation target management with rustup target add for dozens of platforms
  • Component management for optional tools like miri, rust-src, and llvm-tools
  • Automatic toolchain selection per project via rust-toolchain.toml
  • Self-update capability that keeps rustup itself current alongside toolchains

Comparison with Similar Tools

  • asdf — generic version manager for many languages; rustup is Rust-specific with deeper component and target management
  • Nix — reproducible package manager; rustup provides Rust-specific ergonomics like target and component management
  • mise — polyglot dev tool manager; rustup remains the canonical way to manage Rust with full component support
  • Manual download — pre-built binaries are available but lack multi-version and cross-target management
  • cargo-binstall — installs Rust binaries; rustup manages the compiler toolchain itself

FAQ

Q: How do I install a specific nightly version? A: Use rustup install nightly-2026-01-15 to pin a dated nightly, then set it as default or add a rust-toolchain.toml file.

Q: Can I use rustup in CI/CD? A: Yes. Most CI services pre-install rustup. Use rustup show to verify the toolchain and rustup target add to set up cross-compilation targets.

Q: Does rustup work offline? A: Not for installation, but once toolchains are downloaded they work fully offline. You can also set up a local mirror with RUSTUP_DIST_SERVER.

Q: How do I uninstall a toolchain I no longer need? A: Run rustup toolchain uninstall nightly to remove a specific toolchain and free disk space.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。