Skip to main content

Rustup Toolchain Installer Usage Guide

info

Some content in this document may have been translated by AI.

Important Notes

The mirror site only keeps the latest stable, beta, and nightly versions. If you need to install older toolchains using rustup, please use the official source.

Windows Users

First-time Rust Toolchain Installation

Before using Rust (MSVC), you may need to install the MSVC compiler toolchain (Microsoft C++ Build Tools).

Use PowerShell to run the following script. (During the exe download process, Windows anti-malware service will scan the file, which may take about half a minute.)

Select Backend
MSVC
Select Architecture
x64
Invoke-WebRequest -OutFile ${env:TEMP}/rustup-init.exe https://mirrors.hust.edu.cn/rustup/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe
$env:RUSTUP_DIST_SERVER = "https://mirrors.hust.edu.cn/rustup"
$env:RUSTUP_UPDATE_ROOT = "https://mirrors.hust.edu.cn/rustup/rustup"
& "${env:TEMP}\rustup-init.exe"
About Rust Compiler Backend on Windows

If you don't know which to choose, please use the MSVC version.

caution

The above installation script only enables the mirror source during installation. It will revert to the official source on the next update. If you need to permanently enable the mirror source, please refer to the next section.

Permanently Enable Mirror Source for Rustup Toolchain

Method 1: Add environment variables in "System - Advanced System Settings - Environment Variables".

  • Variable name: RUSTUP_DIST_SERVER, value: https://mirrors.hust.edu.cn/rustup.
  • Variable name: RUSTUP_UPDATE_ROOT, value: https://mirrors.hust.edu.cn/rustup/rustup.

Method 2 (Recommended): Execute the following PowerShell script directly:

[System.Environment]::SetEnvironmentVariable("RUSTUP_DIST_SERVER", "https://mirrors.hust.edu.cn/rustup", "User")
[System.Environment]::SetEnvironmentVariable("RUSTUP_UPDATE_ROOT", "https://mirrors.hust.edu.cn/rustup/rustup", "User")

*nix Users

First-time Rust Toolchain Installation

Considering that the network environment of the official website's https://sh.rustup.rs script may be unstable, we have mirrored this script.

Execute the following command directly to complete the installation of the Rust toolchain.

Use installation script mirror
RUSTUP_DIST_SERVER="https://mirrors.hust.edu.cn/rustup" \
RUSTUP_UPDATE_ROOT="https://mirrors.hust.edu.cn/rustup/rustup" \
curl -sSf https://mirrors.hust.edu.cn/rustup/rustup.sh | sh

Long-term Use

Add the following content to your .bashrc, .zshrc or other profile files.

export RUSTUP_DIST_SERVER="https://mirrors.hust.edu.cn/rustup"
export RUSTUP_UPDATE_ROOT="https://mirrors.hust.edu.cn/rustup/rustup"
Choose your prefered domain
mirrors.hust.edu.cn
This domain is Dual Stack
Enable HTTPS