How to Install the Rust Compiler on macOS

For this tutorial, we will walk you through the process of download and setting up the Rust compiler on your macOS.

How to Install the Rust Compiler on macOS

Rust Lang or Rust is a free and open-source general purpose programming language. It is described as one of the most fast and powerful programming language of our modern age with incredible features such as memory safety without garbage collection.

Rust is mainly known in high performance environments such as compilers, game engines, drivers, operating systems and more. It is also the pioneer in web components and technologies such as web-assembly.

One of the most revolutionary features is that it achieves memory safety without garbage collection allowing low level memory management but still retains security.

Why Rust?

Some of the best features of Rust include:

  1. Cross-platform support.
  2. Ridiculously fast and efficient
  3. Safe memory allocation.
  4. One of the best compilers with helpful error messages and suggestions.
  5. type inference support.
  6. pattern matching
  7. Guaranteed memory safety
  8. Quick and Easy testing and debugging.

Let's dive in.

macOS Install Rust

To install Rust on your macOS, launch your browser and navigate into the resource below;

Select the provided installer script and paste it into your terminal.

curl --proto '=https' --tlsv1.2 -sSf | sh

Wait for the download to proceed and you'll see an output as shown:

Select 1 to proceed with installation.

The installer will download all the required packages and install them on your system.

Finally, run the command:

source "$HOME/.cargo/env"

Once completed, you can verify the rust compiler is installed using the rustc command as shown:

rustc --version

The command will return an output as shown:

rustc 1.62.1 (e092d0b6b 2022-07-16)

Simple Rust Program

To get started with rust, we can create a simple hello world program.

Start by creating a file ending in .rs file:


Edit the file;


Add the hello world code as shown:

fn main() {
	println!("Hello world");

Save the file and close.

Finally, compile the program with the command:


Once compilation is complete, you can run the program:



Hello world

And with that, you have successfully installed the Rust compiler on macOS and compiled a simple hello world program.


We hope you enjoyed this tutorial, stay tuned for more and feel free to share or leave a comment down below.

Thanks for reading!

If you enjoy our content, please consider buying us a coffee to support our work:

Table of Contents
Great! Next, complete checkout for full access to GeekBits.
Welcome back! You've successfully signed in.
You've successfully subscribed to GeekBits.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.