centos7安装rustup

rust安装,因为被墙的原因,在国内几乎很难安装,需要通过代理安装。但是rustup却很容易,一般在linux下,通过官方指定的下列语句,基本可以安装rustup。

curl -sSf https://sh.rustup.rs | sh

安装

[root@VM_68_155_centos pingcap]# curl https://sh.rustup.rs -sSf | sh -s
info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust programming 
language, and its package manager, Cargo.

It will add the cargo, rustc, rustup and other commands to Cargo's bin 
directory, located at:

  /root/.cargo/bin

This path will then be added to your PATH environment variable by modifying the
profile files located at:

  /root/.profile
  /root/.bash_profile

You can uninstall at any time with rustup self uninstall and these changes will
be reverted.

Current installation options:

   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
1

info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2018-03-01, rust version 1.24.1 (d3ae9a9e0 2018-02-27)
info: downloading component 'rustc'

输入1选择默认安装。

这一步完成之后,会在根目录下生成.cargo和.rustup文件夹,.cargo文件夹中会有一个bin目录,里面会有rustup可执行程序。我们配置一个国内rust源,提高依赖下载速度,只需要在.cargo文件夹下新建一个文件config配置一下。

可以设置中科大镜像源,这里非常感谢中科大为中国ruster提供了方便,不仅可以通过中科大提供的源来加速安装,还可以直接通过中科大提供的地址下载某一个版本编译好的rust安装程序。

vi /root/.cargo/config

[registry]
index = "https://mirrors.ustc.edu.cn/crates.io-index/"
[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/"

接下来就可以通过rustup命令来安装rust,并且可以指定rust版本号,这一点非常重要,很多rust程序编译,就需要对应的rust版本来编译。

[root@VM_68_155_centos pingcap]# rustup override set nightly-2018-01-12
info: syncing channel updates for 'nightly-2018-01-12-x86_64-unknown-linux-gnu'
info: latest update on 2018-01-12, rust version 1.25.0-nightly (73ac5d6a8 2018-01-11)
info: downloading component 'rustc'
 47.3 MiB /  47.3 MiB (100 %)  14.8 MiB/s ETA:   0 s                
info: downloading component 'rust-std'
 65.7 MiB /  65.7 MiB (100 %)   2.8 MiB/s ETA:   0 s                
info: downloading component 'cargo'
  4.2 MiB /   4.2 MiB (100 %)   2.2 MiB/s ETA:   0 s                
info: downloading component 'rust-docs'
  4.6 MiB /   4.6 MiB (100 %)   2.5 MiB/s ETA:   0 s                
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'
info: override toolchain for '/data/tidb/src/github.com/pingcap' set to 'nightly-2018-01-12-x86_64-unknown-linux-gnu'

  nightly-2018-01-12-x86_64-unknown-linux-gnu installed - rustc 1.25.0-nightly (73ac5d6a8 2018-01-11)

安装完成,通过查看版本号,查看安装结果。

[root@VM_68_155_centos tikv]# rustup --version
rustup 1.11.0 (e751ff9f8 2018-02-13)
[root@VM_68_155_centos tikv]# rustc --version
rustc 1.25.0-nightly (73ac5d6a8 2018-01-11)
[root@VM_68_155_centos tikv]# cargo --version
cargo 0.25.0-nightly (a88fbace4 2017-12-29)
值得一提的是,rustup不仅可以指定下载的版本安装,还可以指定机器中已经下载安装的rust为当前环境的tool chain。而无须重复安装。
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luffy5459

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值