How to install Rust on macOS

Rust development on macOS needs the compiler, Cargo, and rustup available in the user's shell before local projects can build. The upstream rustup installer gives a Mac the stable Rust toolchain used by Rust's own documentation and keeps later toolchain changes under the developer account.

The installer places command proxies in ~/.cargo/bin and manages downloaded toolchains under ~/.rustup. A new terminal session usually sees that path automatically, but the current terminal may need the Cargo environment file loaded before rustc, cargo, and rustup resolve.

A Mac also needs Apple command line tools because Cargo uses the system linker when it builds native binaries. A throwaway Cargo project verifies the installed compiler, package manager, linker, and default project template before the sample directory is removed.

Steps to install the Rust toolchain on macOS:

  1. Check that Apple command line tools are installed.
    $ xcode-select -p
    /Library/Developer/CommandLineTools

    If macOS reports that no developer tools are installed, run xcode-select --install and finish the installer before continuing.

  2. Install rustup and the default stable Rust toolchain.
    $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
    info: downloading installer
    info: default host triple is aarch64-apple-darwin
    info: default toolchain set to stable-aarch64-apple-darwin
    
      stable-aarch64-apple-darwin installed - rustc 1.96.0 (ac68faa20 2026-05-25)
    
    Rust is installed now. Great!

    -y accepts the default install profile and stable toolchain. Run the installer as a normal macOS user, not with sudo, so rustup can update user-owned files later.

  3. Load the Cargo environment into the current terminal.
    $ . "$HOME/.cargo/env"

    Opening a new Terminal window after installation normally has the same effect because rustup updates the user shell profile.

  4. Confirm the active Rust toolchain.
    $ rustup show active-toolchain
    stable-aarch64-apple-darwin (default)

    Intel Macs report stable-x86_64-apple-darwin instead of stable-aarch64-apple-darwin.

  5. Check the Rust compiler version.
    $ rustc --version
    rustc 1.96.0 (ac68faa20 2026-05-25)
  6. Check the Cargo version.
    $ cargo --version
    cargo 1.96.0 (30a34c682 2026-05-25)
  7. Create a sample Cargo project.
    $ cargo new hello-rust
        Creating binary (application) `hello-rust` package
    note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
  8. Run the sample project through Cargo.
    $ cargo run --manifest-path hello-rust/Cargo.toml
       Compiling hello-rust v0.1.0 (/Users/alex/hello-rust)
        Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.93s
         Running `hello-rust/target/debug/hello-rust`
    Hello, world!
  9. Remove the sample project.
    $ rm -r hello-rust

    This removes only the throwaway verification project. It does not remove rustup, Cargo, or the installed Rust toolchain.