Rust开发环境安装

Rust开发环境安装

在线尝试Rust开发:https://play.rust-lang.org/
一般不直接下载编译器,使用rustup工具安装如rust相关的一整套工具链

安装步骤

在线安装

获取rustup-init
  • Window版本:官网下载rustup-init
  • Unix使用以下命令进行安装(root用户安装需要添加-y参数):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

也可通过以下链接下载对应版本的安装包

安装工具

window下直接运行,会弹出命令行;Unix下使用命令行安装会直接弹出提示,使用安装包的可以直接运行./rustup-init

pierce@mobile:~$ ./rustup-init 

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 bin directory, located at:

  /home/casa/.cargo/bin                  #cargo安装路径

This can be modified with the CARGO_HOME environment variable.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/casa/.rustup                      #rustup安装路径

This can be modified with the RUSTUP_HOME environment variable.

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

/home/casa/.profile                     #修改PATH环境变量的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                        #工具链版本(nightly/beta/stable/none)
               profile: default                       #工具链的完整性选取(minimal/default/complete)
  modify PATH variable: yes                           #是否修改PATH环境变量

1) Proceed with installation (default)                #安装
2) Customize installation                             #自定义安装
3) Cancel installation                                #取消安装
>                                                     #<--输入你想要的操作的编号

自定义安装根据提示更改完配置信息,确认后安装即可。

安装工具链

如果安装rustup时toolchain选取为none,或者想要更换rust工具链版本,可使用以下命令安装nightly/beta/stable中任一版本的工具链

$ rustup install nightly/beta/stable
$ rustup default nightly/beta/stable

离线安装

下载对应平台的离线安装包,解压并运行目录下的install.sh即可。

platformstablebetanightly
aarch64-unknown-linux-gnutar.gztar.gztar.gz
arm-unknown-linux-gnueabitar.gztar.gztar.gz
arm-unknown-linux-gnueabihftar.gztar.gztar.gz
armv7-unknown-linux-gnueabihftar.gztar.gztar.gz
i686-apple-darwinpkgpkgpkg
i686-pc-windows-gnumsimsimsi
i686-pc-windows-msvcmsimsimsi
i686-unknown-linux-gnutar.gztar.gztar.gz
mips-unknown-linux-gnutar.gztar.gztar.gz
mips64-unknown-linux-gnuabi64tar.gztar.gztar.gz
mips64el-unknown-linux-gnuabi64tar.gztar.gztar.gz
mipsel-unknown-linux-gnutar.gztar.gztar.gz
powerpc-unknown-linux-gnutar.gztar.gztar.gz
powerpc64-unknown-linux-gnutar.gztar.gztar.gz
powerpc64le-unknown-linux-gnutar.gztar.gztar.gz
s390x-unknown-linux-gnutar.gztar.gztar.gz
x86_64-apple-darwinpkgpkgpkg
x86_64-pc-windows-gnumsimsimsi
x86_64-pc-windows-msvcmsimsimsi
x86_64-unknown-freebsdtar.gztar.gztar.gz
x86_64-unknown-linux-gnutar.gztar.gztar.gz
x86_64-unknown-linux-musltar.gztar.gztar.gz
x86_64-unknown-netbsdtar.gztar.gztar.gz

版权声明:本文为mr_black_man原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。