Skip to content

Beginner · Getting started with Rust · topic 2 of 50 · 20 min

Installing Rust with rustup

Explanation

You install Rust with rustup, the official installer and version manager. It gives you rustc (the compiler), cargo (the build tool and package manager) and the standard library. On Windows you also need the Microsoft C++ build tools; on any system, VS Code with the rust-analyzer extension is a good editor.

Why an installer called rustup?

Rust releases a new stable version every six weeks. You do not want to download and reinstall by hand each time. rustup is a small program that installs Rust and keeps it up to date. It can also hold several versions side by side, called toolchains.

What gets installed

ToolWhat it does
rustupInstalls and updates Rust, and switches between toolchains
rustcThe compiler: turns .rs files into a program
cargoThe build tool and package manager: creates projects, builds, runs, tests and downloads libraries
stdThe standard library: ready-made code for text, files, collections, threads and more
rustfmt and clippyA code formatter and a linter (a tool that warns about bad patterns)

Installing on Windows

  1. Open rustup.rs in your browser and download rustup-init.exe.
  2. Run it. If it says the Microsoft C++ build tools are missing, let it install them, or install "Build Tools for Visual Studio" with the "Desktop development with C++" option. Rust uses Microsoft's linker on Windows. A linker joins compiled pieces into one .exe file.
  3. Choose the default installation (option 1).
  4. Close and reopen your terminal so it can find the new commands.

Installing on macOS and Linux

bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
The official one-line installer from rustup.rs. On macOS you may also need: xcode-select --install

Check that it worked

bash
rustc --version
cargo --version
rustup --version
Each command prints a version number. If you see "command not found", reopen the terminal or check that ~/.cargo/bin is on your PATH.

PATH is the list of folders your terminal searches for commands. rustup adds the folder with cargo and rustc to it, but only new terminal windows see the change.

Toolchains and updates

  • stable: the normal version for real work. Use this.
  • beta: the next stable version, for testing.
  • nightly: built every night, with experimental features. Some tools need it, but beginners do not.
bash
rustup update
rustup toolchain list
rustup component add clippy rustfmt
Update to the newest stable, list installed toolchains, and add tools if they are missing.

An editor: VS Code and rust-analyzer

Install VS Code, then the extension named rust-analyzer (from the rust-lang publisher). It shows types as you type, underlines errors before you compile, completes code and jumps to definitions. It is the official language server for Rust. A language server is a background program that gives an editor smart features for one language.

Tip: No installation yet, or on a phone? Use the Rust Playground at play.rust-lang.org. It compiles and runs small programs in the browser and can share a link to your code.

Common mistakes

  • Installing Rust from a random website or an old package manager version. Use rustup so updates are easy.
  • On Windows, skipping the C++ build tools. You then see "linker link.exe not found". Install the build tools and try again.
  • Running rustc in an old terminal window right after installing. Open a new one.
  • Installing nightly "to get the newest". Stable is what tutorials and jobs expect.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Installing Rust with rustup · 1/7

rustup = installer + updater

Let us install Rust. The official way is a small tool called rustup.

Prefer a video by a teacher? Find free videos on “install rust rustup windows vs code rust-analyzer” on YouTube ↗

In real life: Setting up a new laptop at work

A new developer joins a fintech startup in Bengaluru. The team README says: "Install Rust with rustup, then run cargo build." Because everyone uses rustup and the same stable toolchain, the project builds the same way on her Windows laptop, a teammate's MacBook and the Linux build server. A rust-toolchain.toml file in the project can even pin the exact version so nobody gets surprises.

bash
rustup update
rustc --version
cargo build
The first three commands on a new machine.

Practice (0/2 done)

Task 1 · Question

You just installed Rust on Windows, but the terminal says cargo is not recognised. What should you try first?

Task 2 · Practice

Install Rust on your computer (or open the Rust Playground if you cannot install). Record the output of the version commands.

Quick quiz

Question 1

1.What is rustup?

Question 2

2.Which toolchain should a beginner use?

Question 3

3.On Windows you see "linker link.exe not found". What is missing?

Question 4

4.What does rust-analyzer give you?

Read more (free)

Before this, learn

This topic builds on these. If something here feels new, open them first.

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What is rustup?

Answer: The official installer and toolchain manager

rustup installs Rust, updates it and switches between toolchains.

Which toolchain should a beginner use?

Answer: stable

stable is tested and is what tutorials, books and employers expect.

On Windows you see "linker link.exe not found". What is missing?

Answer: The Microsoft C++ build tools

Rust on Windows (the default MSVC toolchain) uses Microsoft's linker from the C++ build tools.

What does rust-analyzer give you?

Answer: Smart editor features: errors, types and completion as you type

It is a language server that powers editor features for Rust.

Which tool finds suspicious code that still compiles, like a wrong Printf format?Related

Answer: go vet

go vet reports likely mistakes such as format strings that do not match their arguments.

From Installing Go and the go command

Where does a cargo project keep its main code?Related

Answer: src/main.rs

cargo new puts the starting code in src/main.rs.

From Your first program and cargo

What do you need to install to BUILD C# programs?Related

Answer: The .NET SDK

The SDK has the compiler and the dotnet tools. The runtime alone can only run built apps.

From Installing .NET and using the dotnet CLI

What do you need to build an iOS app?Related

Answer: A Mac with Xcode

Apple requires Xcode on macOS.

From Installing Flutter

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 2 more topics in “Getting started with Rust” before its exam: Your first program and cargo, Variables, mutability, shadowing and constants.
  2. Module 1 exam: Getting started with Rust · 12 questions · 20 min, without help. 4 topics of this module still to finish first.
  3. Then the next module, Types, control flow and functions. 50 topics left in the course before the final exam.

← Previous: What Rust is and why learn it