MacOS 上如何安装 Rust

由于想尝试一下 actix-web,需要安装 Rust,所以这里介绍下 MacOS 如何安装 Rust。

安装

  • 安装时建议使用rustup,因为它可以让你在不同版本的Rust之间切换,而不需要下载任何额外的东西。
brew install rustup
  • 使用rustup安装Rust编译器(rustc)和Rust包管理器(cargo)。
rustup-init
  • 如果没有什么特殊要求选1默认,如果你想自定义安装 Rust,选择2。
Current installation options:


   default host triple: x86_64-apple-darwin
     default toolchain: stable
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
  • 这里执行完后运行rustc --version并不会显示版本,发现有这么一句话To configure your current shell run source $HOME/.cargo/env,原来要添加环境变量。
source $HOME/.cargo/env
  • 运行rustc --version,打印版本,说明安装成功。
rustc 1.44.1 (c7087fe00 2020-06-17)

你可能感兴趣的:(MacOS 上如何安装 Rust)