rustup 可以帮助我们安装不同版本的rust 编程需要的工具连,同时可以方便的进行不同版本
之间的切换,类似nodejs 的nvm,n, ruby 的 rvm python 的 venv 。。。

rustup 基本使用

我们在首次使用安装脚本,或者安装包安装完成rust 之后就会附带rustup了,对于需要使用不同版本
的流程如下:

  • 选择一个版本,rust 提供了不同的channnel(nightly,stabel,beta. date 格式..)
  • 使用rustup install 指定版本,或者rustup toolchain install
  • 指定rustup default version 进行版本切换
  • 使用rustup toolchain list 或者rustup show检查切换配置

rustup 帮助

  • toolchain
  1. rustup-toolchain
  1. Modify or query the installed toolchains
  1. USAGE:
  1. rustup toolchain <SUBCOMMAND>
  1. FLAGS:
  1. -h, --help Prints help information
  1. SUBCOMMANDS:
  1. list List installed toolchains
  1. install Install or update a given toolchain
  1. uninstall Uninstall a toolchain
  1. link Create a custom toolchain by symlinking to a directory
  1. help Prints this message or the help of the given subcommand(s)
  1. DISCUSSION:
  1. Many `rustup` commands deal with *toolchains*, a single
  1. installation of the Rust compiler. `rustup` supports multiple
  1. types of toolchains. The most basic track the official release
  1. channels: 'stable', 'beta' and 'nightly'; but `rustup` can also
  1. install toolchains from the official archives, for alternate host
  1. platforms, and from local builds.
  1. Standard release channel toolchain names have the following form:
  1. <channel>[-<date>][-<host>]
  1. <channel> = stable|beta|nightly|<version>
  1. <date> = YYYY-MM-DD
  1. <host> = <target-triple>
  1. 'channel' is either a named release channel or an explicit version
  1. number, such as '1.8.0'. Channel names can be optionally appended
  1. with an archive date, as in 'nightly-2017-05-09', in which case
  1. the toolchain is downloaded from the archive for that date.
  1. Finally, the host may be specified as a target triple. This is
  1. most useful for installing a 32-bit compiler on a 64-bit platform,
  1. or for installing the [MSVC-based toolchain] on Windows. For
  1. example:
  1. $ rustup toolchain install stable-x86_64-pc-windows-msvc
  1. For convenience, elements of the target triple that are omitted
  1. will be inferred, so the above could be written:
  1. $ rustup default stable-msvc
  1. rustup can also manage symlinked local toolchain builds, which are
  1. often used to for developing Rust itself. For more information see
  1. `rustup toolchain help link`.

一个简单安装例子

比如我们需要安装一个nightly-2019-01-17 , 这个格式遵循上边的约定

  • 安装如下:
  1. rustup toolchain install nightly-2019-01-17

信息如下:

可以看出信息还是很详细的(我们同时也知道了版本)

  1. rustup toolchain install nightly-2019-01-17
  1. info: syncing channel updates for 'nightly-2019-01-17-x86_64-apple-darwin'
  1. 316.6 KiB / 316.6 KiB (100 %) 223.0 KiB/s in 1s ETA: 0s
  1. info: latest update on 2019-01-17, rust version 1.33.0-nightly (ceb251214 2019-01-16)
  1. info: downloading component 'rustc'
  1. 78.6 MiB / 78.6 MiB (100 %) 537.6 KiB/s in 3m 6s ETA: 0s
  1. info: downloading component 'rust-std'
  1. 48.0 MiB / 51.3 MiB ( 94 %) 44.8 KiB/s in 3m 14s ETA: 1m 15s
  1. 48.0 MiB / 51.3 MiB ( 94 %) 48.0 KiB/s in 3m 16s ETA: 1m 8s
  1. 51.3 MiB / 51.3 MiB (100 %) 282.4 KiB/s in 3m 36s ETA: 0s
  1. info: downloading component 'cargo'
  1. 3.4 MiB / 3.4 MiB (100 %) 388.1 KiB/s in 9s ETA: 0s
  1. info: downloading component 'rust-docs'
  1. 8.5 MiB / 8.5 MiB (100 %) 606.9 KiB/s in 18s ETA: 0s
  1. info: installing component 'rustc'
  1. 78.6 MiB / 78.6 MiB (100 %) 8.9 MiB/s in 7s ETA: 0s
  1. info: installing component 'rust-std'
  1. 51.3 MiB / 51.3 MiB (100 %) 12.1 MiB/s in 4s ETA: 0s
  1. info: installing component 'cargo'
  1. info: installing component 'rust-docs'
  1. 8.5 MiB / 8.5 MiB (100 %) 1.3 MiB/s in 6s ETA: 0s
  1. nightly-2019-01-17-x86_64-apple-darwin installed - rustc 1.33.0-nightly (ceb251214 2019-01-16)
  1. info: checking for self-updates
 
  • 启动新的为default
  1. rustup default nightly-2019-01-17
  • 查看toolchain
  1. rustup toolchain list

效果:

  1. stable-x86_64-apple-darwin
  1. nightly-2019-01-17-x86_64-apple-darwin (default)
  1. nightly-x86_64-apple-darwin
 
  • 配置default

    我们可以使用 <channel>[-<date>][-<host>] 格式,也可以使用 toolchain list 看到的版本

  1. rustup default nightly-2019-01-17

效果

  1. info: using existing install for 'nightly-2019-01-17-x86_64-apple-darwin'
  1. info: default toolchain set to 'nightly-2019-01-17-x86_64-apple-darwin'
  1. nightly-2019-01-17-x86_64-apple-darwin unchanged - rustc 1.33.0-nightly (ceb251214 2019-01-16)
  • 检查default
  1. rustup show

效果:

  1. Default host: x86_64-apple-darwin
  1. installed toolchains
  1. --------------------
  1. stable-x86_64-apple-darwin
  1. nightly-2019-01-17-x86_64-apple-darwin (default)
  1. nightly-x86_64-apple-darwin
  1. active toolchain
  1. ----------------
  1. nightly-2019-01-17-x86_64-apple-darwin (default)
  1. rustc 1.33.0-nightly (ceb251214 2019-01-16)
 
 

或者:

  1. rustup toolchain list

效果:

  1. stable-x86_64-apple-darwin
  1. nightly-2019-01-17-x86_64-apple-darwin (default)
  1. nightly-x86_64-apple-darwin

说明

因为rust 语言的变动,可能经常碰到编译问题(依赖别人的包),通过rustup 的版本管理,基本上可以解决我们
实际碰到的问题,同时对于不同版本包的问题,可以结合github 的issue 进行查看(好多时候都会找到的)

参考资料

https://forge.rust-lang.org/channel-layout.html
https://forge.rust-lang.org/
https://forge.rust-lang.org/releases.html
https://rust-lang.github.io/rustup-components-history/index.html

rustup 使用的更多相关文章

  1. rustup命令速度慢

    通过以下命令更换镜像: $ENV:RUSTUP_DIST_SERVER='https://mirrors.ustc.edu.cn/rust-static' $ENV:RUSTUP_UPDATE_ROO ...

  2. 不用rustup,Windows下gnu版Rust安装与开发环境配置

    写在前面 本文介绍了在不使用rustup的情况下,在Windows上安装gnu版的Rust,并配置开发环境(VSCode + rust-analyzer,CLion + IntelliJ Rust)的 ...

  3. 深入体验bash on windows,在windows上搭建原生的linux开发环境,酷!

    今年微软Build 2016大会最让开发人员兴奋的消息之一,就是在Windows上可以原生运行Linux bash,对开发人员来说,这是一个喜闻乐见的消息. 1 安装 你必须安装开发者预览版本,才能使 ...

  4. 我的Shell + VIM配置

    1. 安装powerline-shell 下载powerline-shell # cd /opt/ # git clone https://github.com/milkbikis/powerline ...

  5. bash on windows

    bash on windows 今年微软Build 2016大会最让开发人员兴奋的消息之一,就是在Windows上可以原生运行Linux bash,对开发人员来说,这是一个喜闻乐见的消息. 1 安装 ...

  6. Rust语言之HelloWorld

    Rust语言之HelloWorld 参考文档: http://doc.crates.io/guide.html 1 什么是Cargo 相当于maven/ant之于java, automake之于c, ...

  7. Rust语言

    Rust语言 https://doc.rust-lang.org/stable/book/ http://www.phperz.com/article/15/0717/141560.html Rust ...

  8. ycmd for emacs 代码自动补全

    YCMD FOR EMACS Table of Contents 1. 安装 1.1. 下载 1.2. 安装相关依赖 1.3. 更新submodules 1.4. 安装 2. 配置 1 安装   1. ...

  9. rust debug之基于pdb

    方法一: 用visual studio 步骤: 安装msvc工具链 rustup toolchain install stable-x86_64-pc-windows-msvc 切换到该工具链 rus ...

随机推荐

  1. Oracle--(Hierarchical Queries)层级查询(用于部门层级等)

    原网址:https://www.cnblogs.com/guofeiji/p/5291486.html 如果表中包含层级数据,可以使用层级查询子句按层级顺序选择数据行,形成层级树,形式如下: 下面是层 ...

  2. CentOS7搭建jenkins

    一.概述 Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. 安装环境 操作系统:centos ...

  3. 删除elasticsearch 30天前的所有索引

    我的索引格式为 xxx-xxx-xxx-2019.06.27 xxx-xxxx-2019.06.27 脚本思路: 获取目前 es上所有索引,以日期进行拆分,然后用索引时间对比一个月前的日期,日期小于一 ...

  4. ODBC数据导入

    这个方法其实是导入excel 首先进入pl/sql dev (1):tools-->ODBC importer (2):点击connect,选择需要导入的excel (3):如果事先数据库中没有 ...

  5. busybox测试dns问题

    获取svc [root@master01 ~]# kubectl get svc NAME                 TYPE        CLUSTER-IP       EXTERNAL- ...

  6. wind安装Jenkins+sonar+jdk

    最近公司在用Jenkins持续集成软件,自己研究的头痛,而且还是和C#项目融合到一起的,网上看到的都是Java的,我自己配了一套和C#的,和你们分享. Jenkins是一个开源软件项目,旨在提供一个开 ...

  7. SQL server 2008数据库的备份与还原(亲测,效果良好)注意采用单用户模式呀

    .SQL数据库的备份: 1.依次打开 开始菜单 → 程序 → Microsoft SQL Server 2008 → SQL Server Management Studio → 数据库:Dsidea ...

  8. Linux下which、whereis、locate、find命令作用

    1 which 查看可执行文件的位置,也可以找到命令别名 2 whereis 查看文件的位置 3 locate 系统数据库查找文件位置,数据库大约每天更新一次 4 find 根据查找条件,搜寻硬盘查询 ...

  9. 简单后台管理系统框架--HTML练手项目2【Frameset】

    [本文为原创,转载请注明出处] 技术[HTML]   布局[Frameset] 无步骤 <!DOCTYPE html> <html lang="en"> & ...

  10. 笔谈HTTP Multipart POST请求上传文件

    公司一做iOS开发的同事用HTTP Multipart POST请求上传语音数据,但是做了两天都没搞定,项目经理找到我去帮忙弄下.以前做项目只用过get.post,对于现在这个跟服务器交互的表单请求我 ...