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

一个简单安装例子

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

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

信息如下:

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

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

效果:

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

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

rustup default nightly-2019-01-17

效果

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

效果:

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

或者:

rustup toolchain list

效果:

stable-x86_64-apple-darwin
nightly-2019-01-17-x86_64-apple-darwin (default)
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. (转)微服务_.NET Core Consul服务发现与治理

    原文地址:https://www.cnblogs.com/waynechan/p/9354909.html Consul官网:https://www.consul.io Consul下载地址:http ...

  2. C#测试代码、函数、方法执行时间,方便进行系统性能评估

    代码如下: System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start() ...

  3. sparksql读取hive数据报错:java.lang.RuntimeException: serious problem

    问题: Caused by: java.util.concurrent.ExecutionException: java.lang.IndexOutOfBoundsException: Index: ...

  4. P2801 教主的魔法 (线段树)

    题目 P2801 教主的魔法 解析 成天做水题 线段树,第一问区间加很简单 第二问可以维护一个区间最大值和一个区间最小值,若C小于等于区间最小值,就加上区间长度,若C大于区间最大值,就加0 ps:求教 ...

  5. activiti工作流(传智播客)

    1:工作流的概念   说明: 1) 假设:这两张图就是华谊兄弟的请假流程图  2) 图的组成部分:  A. 人物:范冰冰 冯小刚 王中军  B. 事件(动作):请假.批准.不批准     工作流(Wo ...

  6. 两种方法实现在HTML页面加载完毕后运行JS

    JS默认方法: <script type=”text/javascript”> window.onload=function (){ /*代码区域*/ } </script> ...

  7. 对于flex布局的使用心得

    弹性盒子flex: 对于客户端的布局非常有用,不管是平均分配space-around这个属性还是两端对齐space-betwee在页面布局的时候都会有很好的表现. 对于部分内容区域中,具有很多大致内容 ...

  8. Linux内核:关于中断你需要知道的

    1.中断处理程序与其他内核函数真正的区别在于,中断处理程序是被内核调用来相应中断的,而它们运行于中断上下文(原子上下文)中,在该上下文中执行的代码不可阻塞.中断就是由硬件打断操作系统. 2.异常与中断 ...

  9. AIX 静默安装11gR2 RAC

    AIX安装11gR2  RAC   一.1  BLOG文档结构图       一.2  前言部分   一.2.1  导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它 ...

  10. 【TTS】传输表空间Linux asm -> AIX asm

    [TTS]传输表空间Linux asm -> AIX asm 一.1  BLOG文档结构图       一.2  前言部分   一.2.1  导读和注意事项 各位技术爱好者,看完本文后,你可以掌 ...