Rust 安装
Linux
打开终端并输入下面命令:
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
此工具将安装 Rust 的最新稳定版本
如果安装成功,将出现下面这行:
Rust is installed now. Great!
Windows
Windows 上安装 Rust 需要有 C++ 环境,以下为安装的两种方式:
先使用工具 安装 C++ 环境 Microsoft C++ Build Tools
x86_64-pc-windows-msvc
在 RUSTUP-INIT 下载系统相对应的 Rust 安装程序,一路默认即可。
x86_64-pc-windows-gnu
使用 RUSTUP-INIT 弹出的窗口,输入配置
Current installation options:
default host triple: x86_64-pc-windows-msvc
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>2
I'm going to ask you the value of each of these installation options.
You may simply press the Enter key to leave unchanged.
Default host triple? [x86_64-pc-windows-msvc]
x86_64-pc-windows-gnu
Default toolchain? (stable/beta/nightly/none) [stable]
stable
Profile (which tools and data to install)? (minimal/default/complete) [default]
complete
Modify PATH variable? (Y/n)
Y
Current installation options:
default host triple: x86_64-pc-windows-gnu
default toolchain: stable
profile: complete
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
> 1
检查是否安装成功
检查是否正确安装了 Rust,可打开终端并输入下面这行,此时能看到最新发布的稳定版本的版本号、提交哈希值和提交日期:
# rustc -V
rustc 1.60.0 (7737e0b5c 2022-04-04)
# cargo -V
cargo 1.60.0 (d1fd9fe 2022-03-01)
注意 如果 windows 不能输出上述信息,有可能是由于系统变量未设置的问题。
右键此电脑 -> 高级系统设置 -> 环境变量 -> Path -> 新建 -> C:\Users\xxx.cargo\bin;保存即可
rust 同时在本地安装了一个文档服务,rustup doc 让浏览器打开本地文档
卸载
命令行使用 rustup 卸载
$ rustup self uninstall
参考:https://course.rs/about-book.html