RustInstalling Rust (rustup)

Installing Rust (rustup)

Rust is installed and managed through rustup — the official Rust toolchain installer. rustup handles everything: the compiler (rustc), the package manager (cargo), the formatter (rustfmt), the linter (clippy), and language server support (rust-analyzer). It also lets you install multiple Rust versions side-by-side and switch between them with a single command.

This page walks you through installation on every major platform, verifying the install, and configuring your editor.

Installing on Linux or macOS

On Linux and macOS, one curl command handles the entire installation:

Linux / macOS — install rustup

Bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

The script will:

  1. Download the rustup binary for your platform.

  2. Show you what it is about to install and ask for confirmation.

  3. Install rustup, rustc (stable), and cargo under ~/.cargo/bin/.

  4. Update your shell profile (~/.bashrc, ~/.zshrc, etc.) to add ~/.cargo/bin to your PATH.

Press 1 (or Enter) at the prompt to proceed with the default installation. When it finishes you will see:

info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu installed - rustc 1.79.0 (...)

Rust is installed now. Great!

To get started you may need to restart your current shell.
Run the following in your shell then follow the onscreen instructions.

source "$HOME/.cargo/env"

Either open a new terminal or source the env file to make cargo and rustc immediately available in the current session:

Bash
source "$HOME/.cargo/env"
Installing on Windows
  1. Download the rustup installer from the official site: rustup.rs. The file is called rustup-init.exe.

  2. Run rustup-init.exe. A terminal window opens.

  3. Press 1 (or Enter) to select the default installation.

  4. rustup installs the MSVC build tools if they are not already present (it will guide you through this step).

  5. When the installer finishes, close the terminal and open a fresh one so PATH is updated.

MSVC vs GNU toolchain on Windows
By default, Rust on Windows uses the MSVC (Microsoft Visual C++) linker, which requires the Visual Studio Build Tools to be installed. rustup will prompt you to install them automatically. If you prefer the GNU toolchain (MinGW-based) you can install it with `rustup toolchain install stable-x86_64-pc-windows-gnu`, but MSVC is the recommended default for Windows development.
Warning
On Windows, avoid installing Rust inside a path that contains spaces (e.g. `C:\Program Files\Rust`). The default installation path (`C:\Users\YourName\.cargo`) is safe. Paths with spaces can cause obscure build failures with some third-party crates.
WSL on Windows (recommended for Linux tooling)

If you plan to do systems programming, build Linux binaries, or work with Docker on Windows, consider installing Rust inside WSL 2 (Windows Subsystem for Linux) rather than native Windows. WSL gives you a full Ubuntu (or any other distro) environment where the Linux installation path above applies exactly.

Install WSL 2 (run in PowerShell as Administrator)

Bash
wsl --install

Then open your WSL terminal and follow the Linux installation instructions. Your Rust installation inside WSL is completely separate from any native Windows installation.

Verifying the installation

Open a new terminal and run the following commands to confirm everything is installed correctly:

Bash
rustc --version
rustc 1.79.0 (129f3b996 2024-06-10)

Bash
cargo --version
cargo 1.79.0 (ffa9cf99a 2024-06-03)

Bash
rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)

If all three commands print version numbers, Rust is installed and ready.

Success
Create and run your first project to confirm the full toolchain works end to end: `cargo new hello && cd hello && cargo run`. You should see "Hello, World!" printed to the terminal.
What rustup installs

Component

Command

Purpose

rustc

rustc

The Rust compiler — turns .rs source files into executables or libraries

cargo

cargo

Build system and package manager — the tool you use for almost everything

rustup

rustup

Toolchain manager — installs, updates, and switches between Rust versions

rustfmt

cargo fmt

Official code formatter — enforces a consistent style automatically

clippy

cargo clippy

Linting engine — catches common mistakes and suggests idiomatic Rust

rustdoc

cargo doc

Documentation generator — creates HTML docs from doc comments

rust-std

(library)

The Rust standard library, compiled for your target platform

Updating Rust

Rust releases a new stable version every six weeks. Updating to the latest stable release takes one command:

Bash
rustup update
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2024-06-13, rust version 1.79.0 (129f3b996 2024-06-10)
info: downloading component 'rustc'
info: downloading component 'cargo'
info: installing component 'rustc'
info: installing component 'cargo'

  stable-x86_64-unknown-linux-gnu updated - rustc 1.79.0
Tip
Run `rustup update` every few weeks. Rust has a strong stability guarantee — code that compiled on Rust 1.0 still compiles today. Updates bring new features, performance improvements, and better diagnostics, never breaking changes.
Managing toolchains (stable, beta, nightly)

Rust ships three release channels:

  • stable — released every 6 weeks. Fully tested, no breaking changes. Use this for all production code.

  • beta — the next stable release in testing. Good for checking that your code will still compile after the upcoming release.

  • nightly — built from the latest main branch, released every night. Required for some unstable features and compiler plugins (like proptest-macro or certain proc-macros). Not recommended for production.

You can install additional toolchains alongside your default:

Install additional toolchains

Bash
# Install the nightly toolchain
rustup toolchain install nightly

# List all installed toolchains
rustup toolchain list

# Run a specific command with nightly without changing your default
rustup run nightly cargo build

# Override the toolchain for a specific project directory
cd my-project
rustup override set nightly

You can also pin a project to a specific Rust version by creating a rust-toolchain.toml file in the project root:

rust-toolchain.toml

TOML
[toolchain]
channel = "1.79.0"

Anyone who checks out the project and runs cargo build will automatically use that exact toolchain version — rustup downloads it if necessary.

Adding components

Some rustup components are not installed by default but can be added on demand:

Adding extra components

Bash
# Add rust-analyzer (language server, for editor integration)
rustup component add rust-analyzer

# Add the source code for the standard library (needed for some IDE features)
rustup component add rust-src

# Add cross-compilation targets (e.g., compile for WebAssembly)
rustup target add wasm32-unknown-unknown

# Add the LLVM tools preview (for profiling and coverage)
rustup component add llvm-tools-preview
IDE and editor setup

Rust has excellent editor support. The language server (rust-analyzer) provides real-time type inference, autocompletion, inline error display, refactoring, and go-to-definition in any editor that supports the Language Server Protocol.

  • VS Code — install the rust-analyzer extension (ID: rust-lang.rust-analyzer). This is the most popular and best-supported Rust editor setup.

  • IntelliJ / CLion / RustRover — install the official Rust plugin by JetBrains. JetBrains ships a dedicated Rust IDE called RustRover (free for non-commercial use).

  • Neovim — use nvim-lspconfig with rust-analyzer. The rustaceanvim plugin adds extra Rust-specific features.

  • Helix — rust-analyzer is supported out of the box. Run hx . in your project directory.

  • Emacsrustic-mode combined with lsp-mode or eglot gives a full IDE experience.

VS Code setup (recommended)
  1. Install VS Code from code.visualstudio.com.

  2. Open VS Code and go to the Extensions panel (Ctrl+Shift+X on Windows/Linux, Cmd+Shift+X on macOS).

  3. Search for rust-analyzer and install the extension published by The Rust Programming Language (identifier: rust-lang.rust-analyzer).

  4. Open any Rust project folder. rust-analyzer will automatically index your project and start providing IntelliSense.

  5. Optional: also install the CodeLLDB extension for a native Rust debugger with breakpoint support.

Tip
Do not install the older **Rust** extension (identifier `rust-lang.rust`) — it is deprecated. The current, actively maintained extension is **rust-analyzer** (`rust-lang.rust-analyzer`).
PATH configuration

rustup installs all binaries to ~/.cargo/bin (Linux/macOS) or %USERPROFILE%\.cargo\bin (Windows). The installer adds this directory to your PATH automatically, but if commands are not found after installation, add it manually:

Linux / macOS — add to ~/.bashrc or ~/.zshrc

Bash
export PATH="$HOME/.cargo/bin:${PATH}"

Windows PowerShell — add to profile

Bash
[Environment]::SetEnvironmentVariable(
  "Path",
  [Environment]::GetEnvironmentVariable("Path","User") + ";$env:USERPROFILE.cargoin",
  "User"
)

After editing your profile, open a new terminal for the change to take effect.

Uninstalling Rust

If you ever need to completely remove Rust and rustup from your system, one command does it cleanly — no leftover files in system directories:

Bash
rustup self uninstall

This removes rustup itself, all installed toolchains, and all binaries from ~/.cargo/bin.

Quick-start checklist
  • rustup is installed and rustup --version prints a version number.

  • rustc --version prints the stable compiler version.

  • cargo --version prints the Cargo version.

  • A test project (cargo new hello && cd hello && cargo run) prints "Hello, World!".

  • Your editor has rust-analyzer installed and showing inline type hints.

Success
Once all five items on the checklist are green, your Rust environment is fully set up. Head to the next page to write your first real Rust program.