该文章主要讲述在windows10+vscode下如何构建一个完整的rust编译调试环境,以及过程中可能出现的问题。
Rust构造
rust 官方提供了一系列版本、包安装管理工具,如rustup和cargo。
基本组件
rustup
初始化
从rustup.rs官网下载rustup-init.exe(其他平台同理),这个软件是一个初始配置包,会帮助你下载选择版本的rustup和cargo。
打开软件后会显示如下信息(translated):
Welcome to Rust!
欢迎来玩Rust!
This will download and install the official compiler for the Rust programming
language, and its package manager, Cargo.
本向导将会下载并安装Rust官方编译器与包管理工具Cargo。
It will add the cargo, rustc, rustup and other commands to Cargo's bin
directory, located at:
接下来会将cargo、rustc、rustup等二进制文件下载到Cargo的bin文件夹下:
~\.cargo\bin
This path will then be added to your PATH environment variable by modifying the
HKEY_CURRENT_USER/Environment/PATH registry key.
该路径将会添加至当前用户的PATH环境变量中。
You can uninstall at any time with rustup self uninstall and these changes will
be reverted.
你可以自由卸载,并恢复至初。
Current installation options:
当前安装参数:
default host triple: x86_64-pc-windows-msvc
default toolchain: stable
modify PATH variable: yes
1) Proceed with installation (default) 确认并安装(默认)
2) Customize installation 自定义安装
3) Cancel installation 取消安装
> _
默认安装于用户目录下。
该软件默认检查环境变量
CARGO_HOME
、RUSTUP_HOME
,分别为.cargo
、.rustup
设置目录,按需修改(需要注意的是后期包的累积可能会占用巨量的存储空间)。
安装过程中请选择第二项 “Customize installation”