Installing Rust

Before you can write and run Rust code on your machine, you need to install the Rust compiler and its tools.

In this tutorial, we will go through a step-by-step process to install Rust using rustup, set up Cargo (Rust’s package manager and build system), and verify that everything is working correctly.

Why Use Rustup? #

Rustup is the official installer and version manager for Rust. It makes it easy to:

  • Install Rust on your system.
  • Keep Rust updated with a single command.
  • Manage different Rust versions if your projects require them.

Step 1: Install Rustup #

On macOS and Linux #

The recommended way is to open your terminal (Command Prompt, PowerShell, or shell) and run:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shCode language: JavaScript (javascript)

This command downloads and runs the official Rust installation script. You can follow the on-screen instructions and choose the default option unless you have a specific need.

On Windows #

First, go to the official Rust installation page:
https://www.rust-lang.org/tools/install

Second, download rustup-init.exe (the Windows installer).

Third, run rustup-init.exe:

  • When the installer opens, choose the default installation (recommended).
  • This will install both rustc (the Rust compiler) and cargo (Rust’s package manager & build tool)

After installation, Rustup automatically configures your environment variables. To confirm, you can restart your terminal.

Step 2: Verify Installation #

Run the following command in your terminal:

rustc --version

If the installation was successful, you’ll see something like:

rustc 1.89.0 (or newer)Code language: CSS (css)

This confirms that the Rust compiler is installed.

Step 3: Understanding Cargo #

Cargo is Rust’s build system and package manager, installed automatically with Rustup.

You can check if Cargo is installed by running:

cargo --version

Output:

cargo 1.89.0Code language: CSS (css)

Cargo handles:

  • Creating new Rust projects.
  • Compiling your code.
  • Managing external libraries (called crates).
  • Running tests and building documentation.

Step 4: Updating Rust #

Rust has a regular release cycle (every six weeks). To keep your installation up to date, simply run:

rustup update

Summary #

By now, you have installed Rust with Rustup, verified the installation using rustc, and checked that Cargo is available.

With your environment ready, you can now move on to writing the first Rust programs.

Was this Helpful ?