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
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
The script will:
Download the rustup binary for your platform.
Show you what it is about to install and ask for confirmation.
Install
rustup,rustc(stable), andcargounder~/.cargo/bin/.Update your shell profile (
~/.bashrc,~/.zshrc, etc.) to add~/.cargo/binto yourPATH.
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:
source "$HOME/.cargo/env"
Installing on Windows
Download the rustup installer from the official site: rustup.rs. The file is called
rustup-init.exe.Run
rustup-init.exe. A terminal window opens.Press 1 (or Enter) to select the default installation.
rustup installs the MSVC build tools if they are not already present (it will guide you through this step).
When the installer finishes, close the terminal and open a fresh one so
PATHis updated.
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)
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:
rustc --version
rustc 1.79.0 (129f3b996 2024-06-10)
cargo --version
cargo 1.79.0 (ffa9cf99a 2024-06-03)
rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
If all three commands print version numbers, Rust is installed and ready.
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:
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
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-macroor certain proc-macros). Not recommended for production.
You can install additional toolchains alongside your default:
Install additional toolchains
# 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
[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
# 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-lspconfigwith rust-analyzer. Therustaceanvimplugin adds extra Rust-specific features.Helix — rust-analyzer is supported out of the box. Run
hx .in your project directory.Emacs —
rustic-modecombined withlsp-modeoreglotgives a full IDE experience.
VS Code setup (recommended)
Install VS Code from code.visualstudio.com.
Open VS Code and go to the Extensions panel (Ctrl+Shift+X on Windows/Linux, Cmd+Shift+X on macOS).
Search for rust-analyzer and install the extension published by The Rust Programming Language (identifier:
rust-lang.rust-analyzer).Open any Rust project folder. rust-analyzer will automatically index your project and start providing IntelliSense.
Optional: also install the CodeLLDB extension for a native Rust debugger with breakpoint support.
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
export PATH="$HOME/.cargo/bin:${PATH}"Windows PowerShell — add to profile
[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:
rustup self uninstall
This removes rustup itself, all installed toolchains, and all binaries from ~/.cargo/bin.
Quick-start checklist
rustup is installed and
rustup --versionprints a version number.rustc --versionprints the stable compiler version.cargo --versionprints 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.