How to install rust in Windows, Mac and Linux
Installing Rust is a straightforward process on various operating systems, thanks to the rustup
toolchain installer. Here's how you can install Rust on Windows, macOS, and Linux.
Installing Rust on Windows
-
Download Rustup Installer:
- Go to the official Rust website: https://www.rust-lang.org/tools/install
- Click on the "Windows" button to download the installer (
rustup-init.exe
).
-
Run the Installer:
- Execute the downloaded
rustup-init.exe
file. - Follow the on-screen instructions to install Rust. The default options are generally recommended.
- Execute the downloaded
-
Set Up the Environment:
- After installation, open a new Command Prompt or PowerShell window.
- Verify the installation by running:
rustc --version
Installing Rust on macOS
-
Install Homebrew (if not already installed):
- Open the Terminal application.
- Install Homebrew by running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install Rust Using Rustup:
- Use the following command to download and run the Rustup installation script:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Follow the on-screen instructions. The default options are generally recommended.
- Use the following command to download and run the Rustup installation script:
-
Set Up the Environment:
- Restart the Terminal or run
source ~/.cargo/env
to update the current session's environment variables. - Verify the installation by running:
rustc --version
- Restart the Terminal or run
Installing Rust on Linux
-
Install Required Dependencies:
- Open a terminal.
- Ensure you have the required tools for building Rust projects:
- On Debian-based systems (like Ubuntu):
sudo apt update sudo apt install build-essential curl
- On Red Hat-based systems (like Fedora):
sudo dnf groupinstall 'Development Tools' sudo dnf install curl
- On Debian-based systems (like Ubuntu):
-
Install Rust Using Rustup:
- Use the following command to download and run the Rustup installation script:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Follow the on-screen instructions. The default options are generally recommended.
- Use the following command to download and run the Rustup installation script:
-
Set Up the Environment:
- Restart the terminal or run
source ~/.cargo/env
to update the current session's environment variables. - Verify the installation by running:
rustc --version
- Restart the terminal or run
Additional Configuration
-
Updating Rust:
- You can update Rust to the latest version using Rustup:
rustup update
- You can update Rust to the latest version using Rustup:
-
Uninstalling Rust:
- If you need to uninstall Rust, you can do so using Rustup:
rustup self uninstall
- If you need to uninstall Rust, you can do so using Rustup:
Published on: Jun 19, 2024, 10:58 PM