MeshWorld India LogoMeshWorld.

How to Install Rust and Cargo on Ubuntu, macOS, and Windows (2026)

(Updated: Jul 24, 2026)
Listen to ArticleAI Speech
~5 min read narration
100%
How to Install Rust and Cargo on Ubuntu, macOS, and Windows (2026)

Rust is a modern systems programming language empowering developers to build fast, memory-safe, and concurrent software without relying on a garbage collector. Consistently voted among the most loved languages in global developer surveys, Rust powers operating system kernels, WebAssembly modules, CLI utilities, network proxies, and high-performance backend microservices.

Installing Rust using Rustup (the official Rust toolchain installer) provides access to rustc (the compiler), cargo (the package manager and build system), and clippy (the linter).

Whether setting up a development workstation on Ubuntu 24.04 LTS (Noble Numbat), 22.04 LTS, macOS, or Windows, here is the complete 2026 installation guide.

Last updated: July 24, 2026


What are the system prerequisites for installing Rust?

Before executing the Rust installation script, install the required C compiler and linker build tools for your platform:

On Ubuntu / Debian / Linux Mint

Open terminal (Ctrl+Alt+T) and install build-essential and development libraries:

BASH
sudo apt update
sudo apt install -y build-essential gcc pkg-config libssl-dev curl

On macOS

Install Command Line Tools for Xcode via terminal:

BASH
xcode-select --install

On Windows

Download and install the Visual Studio Community build tools with the Desktop development with C++ workload selected, or install WSL2 (Windows Subsystem for Linux).


How do you install Rust and Cargo via Rustup?

The official recommended installer for Rust across all operating systems is Rustup.

Step 1: Run the Official Rustup Installation Script

Execute the following secure HTTPS shell command in your terminal:

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

Step 2: Choose Installation Options

The installer displays a summary of target architecture and directory paths:

TEXT
1) Proceed with standard installation (default - recommended)
2) Customize installation
3) Cancel installation

Type 1 and press Enter to complete the standard installation.

Step 3: Configure Environment Variables

Rustup installs binaries into $HOME/.cargo/bin. Source the environment configuration into your current terminal session:

BASH
source "$HOME/.cargo/env"

To ensure cargo and rustc load automatically in future terminal windows, append the PATH entry to your shell configuration (~/.bashrc or ~/.zshrc):

BASH
echo 'source "$HOME/.cargo/env"' >> ~/.bashrc

Step 4: Verify Installation

Confirm that the Rust compiler (rustc), package manager (cargo), and toolchain manager (rustup) are active:

BASH
rustc --version
cargo --version
rustup --version

Expected output example: rustc 1.8x.x (hash date)


How do you manage Rust toolchains and updates?

rustup allows switching between release channels and target platforms without touching system files.

1. Updating Rust to the Latest Stable Version

Rust releases stable updates every 6 weeks. To update your compiler and tools:

BASH
rustup update

2. Installing and Switching Toolchains (Nightly / Beta)

If a project requires experimental features or nightly compiler flags:

BASH
# Install nightly toolchain
rustup toolchain install nightly

# Set default toolchain to nightly
rustup default nightly

# Switch back to stable toolchain
rustup default stable

3. Adding Cross-Compilation Targets (WebAssembly / Musl)

To compile statically linked binaries using musl or build WebAssembly modules:

BASH
# Add musl target for static Linux binaries
rustup target add x86_64-unknown-linux-musl

# Add WebAssembly target
rustup target add wasm32-unknown-unknown

How do you create and run your first Rust project with Cargo?

Cargo streamlines creating, building, running, and testing Rust applications.

Step 1: Initialize a New Binary Project

Navigate to your workspace directory and create a project:

BASH
cargo new hello_rust
cd hello_rust

This creates a standard project layout:

  • Cargo.toml: Manifest file containing metadata and crate dependencies.
  • src/main.rs: Source file containing the entry point fn main().

Step 2: Review project code

Inspect src/main.rs:

RUST
fn main() {
    println!("Hello, World!");
}

Step 3: Compile and Execute with Cargo

Build and run your application in development mode:

BASH
cargo run

Output:

TEXT
   Compiling hello_rust v0.1.0 (/path/to/hello_rust)
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/hello_rust`
Hello, World!

Step 4: Build a Production Release Binary

When deploying to production, compile with optimizations enabled:

BASH
cargo build --release

The optimized executable will be located in target/release/hello_rust.



Frequently Asked Questions (PAA)

Why shouldn’t I install Rust using sudo apt install rustc?

Linux distribution repositories package specific, static Rust versions that lag behind current compiler releases. Installing via rustup ensures you get the latest stable tools and can update seamlessly.

Is Cargo included when installing Rust via Rustup?

Yes. Rustup automatically installs rustc (the compiler), cargo (the package manager), rust-std (the standard library), and rust-docs (local documentation).

How do I uninstall Rust completely?

To remove Rustup, Cargo, and all installed toolchains from your computer, run:

BASH
rustup self uninstall

Where are Cargo dependencies (crates) stored locally?

Cargo caches downloaded dependencies from Crates.io inside $HOME/.cargo/registry/ and $HOME/.cargo/git/.


Reader Quality Feedback

Did this technical guide help solve your problem?

Suggest Errata ($0)
Vishnu
Primary Author

Vishnu

Founder & Principal Architect at MeshWorld. Senior engineer and instructor specializing in AI agent systems, scalable web architecture, and modern development workflows.

Explore Author Archive
Vishnu
Editorial Reviewer

Vishnu

Founder & Principal Architect at MeshWorld. Senior engineer and instructor specializing in AI agent systems, scalable web architecture, and modern development workflows.

View Dossier
Compute Fuel & Open Testbed
100% Independent & Verified

Fuel High-Density, Zero-Fluff Engineering Deep-Dives

Every guide on MeshWorld is validated on physical Linux nodes and reproducible testbeds. If this article saved you hours of debugging or unblocked production, consider funding our next cluster run.

Weekly Dispatch

Join MeshWorld Dispatch

Get practical tutorials, system blueprints, and curated AI engineering notes straight to your inbox. No fluff, zero spam.

Zero spam. 1-click unsubscribe anytime.Prefer RSS?
Curated Continuations

Up Next in This Domain.

Browse Full Archive