Rust 安装,卸载,nightly/stable版本切换(全局或工作空间),提高下载速度
版权所有,转载前注明原址
时间:2020年1月26日20:10:44
created by:Hpbbs
文章目录
- 1.1 安装
- 1.2 卸载
- 1.3 更新
- 1.4 Rust镜像源切换
- 1.5 Rust nightly/beta/stable版本切换
- 1.5.1 查看已安装版本
- 1.5.2切换到特定版本
- 欢迎关注技术复兴
1.1 安装
1.1.1 下载Rust的安装器
Rust推荐使用rustup程序来管理rust编译器等基本工具,可以官网现在得到Rustup 安装包地址
rustup是安装和管理 Rust 构建版本的工具。 rustup 用于管理不同平台下的 Rust 构建版本并使其互相兼容, 支持安装由 Beta 和 Nightly 频道发布的版本,并支持其他用于交叉编译的编译版本
cargo是rust的包管理器和构建系统工具。它将常用命令集于一身,无需引入其它命令。
rustup程序是rust的安装程序,也是他的版本管理程序,类似于Python的Anaconda发行版的conda工具,非常方便使用管理。cargo是rust的构建工具,暂不介绍,需要明白的是:rustup是管理语言自身的,cargo是管理第三方拓展的。
1.1.2 运行安装器配置安装
此处以stable版本为例
Ok,这就安装成功了,这就是使用了安装器的简洁之处,当然我们需要检测是否安装成功
测试是否安装成功
运行命令行:win+R,输入cmd
输入
rustc --version
或者 rustc -V
若如图出现版本号,便安装成功,如若出现问题,需检测环境变量,如下:
配置 PATH 环境变量
在 Rust 开发环境中,所有工具都安装在 ~/.cargo/bin 目录中,您可以在这里找到包括 rustc、cargo 和 rustup 在内的 Rust 工具链。
Rust 开发者通常会将该目录加入 PATH环境变量中。在安装过程中,rustup 会尝试配置 PATH。 由于不同平台、命令行 Shell 之间存在差异,rustup 中也可能存在 Bug,因此在终端重启或用户重新登录之前,rustup 对 PATH 的修改可能不会生效,甚至完全无效。
如果安装后在终端尝试执行 rustc --version 失败,那么,以上内容就是最可能的原因。
安装指定版本
运行命令行:win+R,输入cmd
输入
rustup install 版本号
1.2 卸载
由于使用安装器 ,卸载Rust环境很简单:
运行命令行:win+R,输入cmd
输入
rustup self uninstall
1.3 更新
运行命令行:win+R,输入cmd
输入
# 更新到目前最新版本
rustup update
# 更新到指定版本号
rustup update _version_number_xxx
不指定版本号命令会对toolchain的所有版本(stable,nightly,beta)的rust更新,如果只安装了其中一个,则只会更新一个。下图是有nightly和stable环境的情形
1.4 Rust镜像源切换
研究Rust时,由于众所周知的原因,发现拉取 crates.io 仓库代码实在太慢,cargo安装下载更新慢的简直让人无法容忍,很多次超时导致引用库没法编译,就把它的更新下载源给替换了,这里可以切到国内镜像(中科大镜像源),配置如下:
找到当前用户目录下 .cargo/ 的.cargo 文件夹,进入.cargo 当前目录,在当前目下创建 config 文件
打开 config 文件,编写以下内容:
[source.crates-io]
registry = “https://github.com/rust-lang/crates.io-index”
replace-with = ‘ustc’
[source.ustc]
registry = “https://mirrors.ustc.edu.cn/crates.io-index”
如果所处的环境中允许使用 git 协议,可以把上述地址改为:
registry = “git://mirrors.ustc.edu.cn/crates.io-index”
可以自行搜索其他镜像源
1.5 Rust nightly/beta/stable版本切换
1.5.1 查看已安装版本
运行命令行:win+R,输入cmd
输入
rustup toolchain list
或者,进入$Home/.rustup/toolchain
查看已安装的版本
1.5.2切换到特定版本
运行命令行:win+R,输入cmd
输入
rustup default stable/nightly/beta
切换全局Rust环境:defalut
rustup default version
若version为nightly,则转为nightly
若version指定stable,则切换为stable
若计算机中为安装nightly或stable,执行命令是将自动下载对应版本
切换工作目录的Rust环境:override
在对应的工作目录打开命令行,如下输入命令:
rustup override set version
version:stable/nightly/beta
PS D:\workspace\rustwp> rustc -V
rustc 1.40.0 (73528e339 2019-12-16)
PS D:\workspace\rustwp> rustup override set nightly
info: using existing install for 'nightly-x86_64-pc-windows-msvc'
info: override toolchain for 'D:\workspace\rustwp' set to 'nightly-x86_64-pc-windows-msvc'nightly-x86_64-pc-windows-msvc unchanged - rustc 1.42.0-nightly (6d3f4e0aa 2020-01-25)PS D:\workspace\rustwp> rustc -V
rustc 1.42.0-nightly (6d3f4e0aa 2020-01-25)
PS D:\workspace\rustwp>
切换工作目录的rust环境为全局默认环境:
rustup override unset
PS D:\workspace\rustwp> rustup override unset
info: override toolchain for 'D:\workspace\rustwp' removed
欢迎关注技术复兴
toolchain介绍
需要明白 toolchain
在rust中的含义:当做版本来认知,方便管理
可以在命令行输入rustup help toolchain
来查看和理解toolchain是什么和如何使用
C:\Users\18755>rustup help toolchainrustup-toolchain
Modify or query the installed toolchainsUSAGE:rustup toolchain <SUBCOMMAND>FLAGS:-h, --help Prints help informationSUBCOMMANDS:list List installed toolchainsinstall Install or update a given toolchainuninstall Uninstall a toolchainlink Create a custom toolchain by symlinking to a directoryhelp Prints this message or the help of the given subcommand(s)DISCUSSION:Many `rustup` commands deal with *toolchains*, a singleinstallation of the Rust compiler. `rustup` supports multipletypes of toolchains. The most basic track the official releasechannels: 'stable', 'beta' and 'nightly'; but `rustup` can alsoinstall toolchains from the official archives, for alternate hostplatforms, and from local builds.Standard release channel toolchain names have the following form:<channel>[-<date>][-<host>]<channel> = stable|beta|nightly|<version><date> = YYYY-MM-DD<host> = <target-triple>'channel' is either a named release channel or an explicit versionnumber, such as '1.8.0'. Channel names can be optionally appendedwith an archive date, as in 'nightly-2017-05-09', in which casethe toolchain is downloaded from the archive for that date.The host may be specified as a target triple. This is most usefulfor installing a 32-bit compiler on a 64-bit platform, or forinstalling the [MSVC-based toolchain] on Windows. For example:$ rustup toolchain install stable-x86_64-pc-windows-msvcFor convenience, omitted elements of the target triple will beinferred, so the above could be written:$ rustup toolchain install stable-msvcThe `rustup default` command may be used to both install and setthe desired toolchain as default in a single command:$ rustup default stable-msvcrustup can also manage symlinked local toolchain builds, which areoften used for developing Rust itself. For more information see`rustup toolchain help link`.
override介绍
PS D:\workspace\rustwp> rustup help override
rustup.exe-override
Modify directory toolchain overridesUSAGE:rustup.exe override <SUBCOMMAND>FLAGS:-h, --help Prints help informationSUBCOMMANDS:list List directory toolchain overridesset Set the override toolchain for a directoryunset Remove the override toolchain for a directoryhelp Prints this message or the help of the given subcommand(s)DISCUSSION:Overrides configure rustup to use a specific toolchain whenrunning in a specific directory.Directories can be assigned their own Rust toolchain with `rustupoverride`. When a directory has an override then any time `rustc`or `cargo` is run inside that directory, or one of its childdirectories, the override toolchain will be invoked.To pin to a specific nightly:$ rustup override set nightly-2014-12-18Or a specific stable release:$ rustup override set 1.0.0To see the active toolchain use `rustup show`. To remove theoverride and use the default toolchain again, `rustup overrideunset`.
Rust 安装,卸载,nightly/stable版本切换(全局或工作空间),提高下载速度相关推荐
- redhat java 多个版本_Linux下安装JDK(多个版本) 切换
1.检查系统是否自带了OpenJDK以及相关安装包,如果有的话则应先将其卸载. 检查命令: java -version rpm -qa | grep java rpm -e --nodeps tzda ...
- mysql 二进制安装卸载_MySQL二进制版本的安装及卸载
二进制版本的mysql是已经编译好的,无需 configure ,make make install 等步骤,只需配置一 下即可使用,卸载也方便,直接删除即可:现在以mysql-standard-4. ...
- Linux下安装卸载jdk8.x版本
文章目录 卸载虚拟机自带的JDK 下载JDK 安装JDK 查看JDK 卸载虚拟机自带的JDK 注意:如果你的虚拟机是最小化安装不需要执行此步骤. 如下命令直接粘贴执行即可,如果没有权限,请加sudo ...
- win10安装Mysql8的两种方式(安装/卸载-图文教程)
前言 命令行窗口打开的方式(任选一种): WIN+R输入cmd (打开普通的窗口) WIN+X 选择Windows PowerShell或者Windows PowerShell(管理员) 系统服务列表 ...
- node安装和配置(node-v12.20.2-x64 ) 以及node版本切换介绍
一.node的安装(可以去文末直接安装nvm管理器,就不用配置了) 1 下载 | Node.js,也可以下载以往版本,window是以msi结尾的文件 2 安装,直接一直安装就行,如果有之前 ...
- windows安装双JDK并实现版本切换
我本来只有一个JDK11,后来因为要用到jdk8,但是我又不想卸载掉11,于是想到了jdk共存,根据百度经验操作作了如下一通操作: 1.删除java.exe,javac.exe,javaw.exe 首 ...
- python安装卸载及查看python版本/第三方包版本
文章目录 1. 在线安装anaconda anaconda下载安装 在线安装第三方库 python 常用第三方包镜像安装 2. 离线安装anaconda 离线安装包下载网址 whl 离线安装 tar ...
- vue专题之vue不同版本安装卸载、版本号查询【三】
背景 vue版本主要是说项目依赖的vue版本,以及当前系统环境安装了的vue脚手架版本,即vue-cli版本 特别是vue-cli版本,通常项目的创建都是通过vue-cli来的 vue-cli高版本创 ...
- 【详细】Ubuntu18.04安装更新显卡驱动、安装CUDA及cuDNN、CUDA版本切换
CUDA安装官方教程:官方教程 cuDNN安装官方教程:官方教程 在配置Pytorch环境的时候,想着尝试一下新版本的pytorch版本Stable(1.10.1)时,发现这个pytorch版本仅支持 ...
最新文章
- 网络分布式软件bonic清除
- EDIUS新建项目工程设置
- mfc 静态框接收tab焦点_目标检测中焦点损失的入门指南
- PicGo github配置
- IOS 设备信息读取
- Java工程师必备技能
- pandas之表格样式
- Android Binder漏洞挖掘技术与案例分享
- android tab 切换动画,Android之ViewPager+TabLayout组合实现导航条切换效果(微信和QQ底部多标签切换)...
- PSIM软件学习---08 C程序块的调用
- Visual Studio新特性:串口监视器和Zephyr支持
- Windows怎么截图
- oracle12c的特点,Oracle12c新特点详述
- Navicat 图形化界面工具
- 三观|腾讯马化腾年刊《三观》年度期刊前言
- GridView分页的实现以及自定义分页样式功能实例
- WPF ListBox控件
- VirtualApp
- 协众信息技术平面设计的8种类型
- Node.js 字符串转换为数字型