Installing multiple versions of Rust on Mac using Homebrew

Many decentralized app (DApp) developers use Rust to create and maintain back-end smart contracts. Here's how to configure your Mac so that you can easily install any version of Rust. If you're a NodeJS developer, you'll likely understand the power behind Node Version Manager or nvm. This is the same thing for Rust.

Step 1 - Install Homebrew

Since we will be using Homebrew manager to install our Rust package manager, here's a quick tutorial on installing Homebrew for Mac.

Step 2 - Install rustup Toolchain Manager

rustup is the toolchain manager that includes the compiler and Cargo's package manager. Rustup will enable you to switch between different versions of Rust without having to download other stuff.

brew install rustup

Step 3 - Install Rust (rustc) Compiler

Use rustup to install the Rust compiler (rustc) and the Rust package manager (Cargo).

rustup-init

Restart Terminal or run one of these commands to activate your changes.

source ~/.bash_profile

or

source ~/.zshrc

Step 4 - Verify Your Installation

rustc --version

Browsing the Rust Toolchain

The most common Rust tools (rustc, cargo, and rustup) will be found within ~/.cargo/bin.

Resources