记录一下Rust环境搭建方案。
一、环境变量
RUSTUP_DIST_SERVER (用于更新 toolchain):
RUSTUP_UPDATE_ROOT (用于更新 rustup):
1 2 |
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup |
二、下载镜像安装脚本
1 |
wget https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh |
三、执行安装脚本
1 |
sh rustup-init.sh |
生成内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
info: downloading installer Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. Rustup metadata and toolchains will be installed into the Rustup home directory, located at: /home/tkxiong/.rustup This can be modified with the RUSTUP_HOME environment variable. The Cargo home directory located at: /home/tkxiong/.cargo This can be modified with the CARGO_HOME environment variable. The cargo, rustc, rustup and other commands will be added to Cargo's bin directory, located at: /home/tkxiong/.cargo/bin This path will then be added to your PATH environment variable by modifying the profile files located at: /home/tkxiong/.profile /home/tkxiong/.bash_profile /home/tkxiong/.bashrc You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host triple: x86_64-unknown-linux-gnu default toolchain: stable (default) profile: default modify PATH variable: yes 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation > |
这里选择1, 默认即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
info: profile set to 'default' info: default host triple is x86_64-unknown-linux-gnu warning: Updating existing toolchain, profile choice will be ignored info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: default toolchain set to 'stable-x86_64-unknown-linux-gnu' stable-x86_64-unknown-linux-gnu unchanged - rustc 1.52.1 (9bc8c42bb 2021-05-09) Rust is installed now. Great! To get started you may need to restart your current shell. This would reload your PATH environment variable to include Cargo's bin directory ($HOME/.cargo/bin). To configure your current shell, run: source $HOME/.cargo/env |
四、配置cargo的环境变量
1 |
source $HOME/.cargo/env |
五、查看安装版本,到这里已经安装成功了
1 2 |
cargo --version cargo 1.52.0 (69767412a 2021-04-21) |
Finish…
【Rust】Rust环境搭建