2 / 35

Rust Basics· 9 min read· Lesson 2 of 35

Installing Rust

Part 1 · Rust. Install Rust with rustup on macOS, Linux or Windows, check it works, set up VS Code with rust-analyzer, or try Rust in your browser.

Before we can make Rusty Bean Café’s first program, we need to set up the kitchen. In this lesson you’ll install Rust, check that it works, and set up a comfortable code editor. If you can’t install anything right now, that’s fine too: there’s a browser-based option at the end.

What we’re installing

Three tools come together as one package:

  • rustup: the installer and updater. It downloads Rust and keeps it up to date. Think of it as the supplier who delivers fresh beans and swaps old equipment for new.
  • rustc: the Rust compiler. It turns your code into a program your computer can run.
  • cargo: Rust’s project manager and build tool. You’ll use Cargo far more than rustc directly. It creates projects, compiles them, runs them and downloads libraries.

You install rustup, and it installs the other two for you.

Opening a terminal

We’ll type a few commands into a terminal (also called a command line or shell). It’s a text window where you type commands instead of clicking buttons.

  • macOS: press Cmd + Space, type Terminal, press Enter.
  • Linux: look for Terminal in your apps menu, or press Ctrl + Alt + T on many systems.
  • Windows: open the Start menu and search for Terminal (or PowerShell).

In the commands below, don’t type the leading $ if you see one in other tutorials. Our code blocks show only what you type.

Installing on macOS and Linux

Paste this command into your terminal and press Enter:

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

Here’s what it does:

  1. curl downloads the official installer script from sh.rustup.rs.
  2. The --proto '=https' --tlsv1.2 options make sure the download only happens over a secure connection.
  3. The | sh part (a “pipe”) hands the downloaded script straight to your shell to run.

The installer asks you to choose an option. Press Enter to accept the default installation. When it finishes, it will say something like Rust is installed now. Great!

Now either close and reopen your terminal, or run:

Terminal window
. "$HOME/.cargo/env"

This tells your current terminal where the new tools live.

Note

On macOS, Rust also needs Apple’s command line developer tools for linking programs. If you later see an error mentioning linker or cc, run xcode-select --install and follow the prompts. On Linux, if you see a similar error, install your distribution’s build tools (for example sudo apt install build-essential on Ubuntu or Debian).

Installing on Windows

  1. Visit rustup.rs (opens in new tab) and download rustup-init.exe (choose the 64-bit version if you’re unsure).
  2. Run it. If it says you need the Visual Studio C++ Build Tools, let it install them for you (that option is offered by the installer). These tools let Rust build Windows programs.
  3. When asked, press Enter to accept the default installation.
  4. When it finishes, close and reopen your terminal.

Warning

The most common Windows hiccup is running cargo in a terminal window that was already open before installing. That old window doesn’t know where Cargo is yet, so you’ll see 'cargo' is not recognized. Close every terminal and open a fresh one.

Checking that it worked

In a fresh terminal, run these two commands:

Terminal window
rustc --version
cargo --version

You should see version numbers, something like:

Output
rustc 1.xx.0 (abcdef123 2026-xx-xx)
cargo 1.xx.0 (abcdef123 2026-xx-xx)

Your exact numbers will be different, and that’s fine. Any recent version works for this course. What matters is that you see a version and not an error such as command not found.

If you do get command not found:

  1. Close all terminals and open a new one, then try again.
  2. On macOS/Linux, run . "$HOME/.cargo/env" and try again.
  3. Still stuck? Re-run the installer. It’s safe to run more than once.

Keeping Rust up to date

A new stable version of Rust comes out every six weeks. To update, run:

Terminal window
rustup update

You don’t need to do this often. Once every month or two is plenty while you’re learning.

Setting up an editor

You can write Rust in any text editor, but a good editor makes life much easier. We recommend Visual Studio Code (VS Code), a free editor from Microsoft that runs on all three operating systems.

  1. Download and install VS Code from code.visualstudio.com (opens in new tab).
  2. Open VS Code and click the Extensions icon in the left sidebar (it looks like four small squares).
  3. Search for rust-analyzer and install the extension published by The Rust Programming Language.

rust-analyzer is a helper that understands Rust code. Once installed, it will:

  • underline mistakes as you type, before you even compile,
  • show the type of each value (you’ll learn about types soon) in light grey text,
  • offer auto-completion, so typing print suggests println!,
  • let you hover over almost anything to see its documentation.

Tip

rust-analyzer works best when you open the whole project folder in VS Code (File → Open Folder…), not just a single file. If its features seem to be missing, that’s usually the reason.

Other editors work well too. RustRover (from JetBrains), Zed, Neovim and Helix all have good Rust support. Use whatever you’re comfortable with.

No install? Try the Rust Playground

The Rust Playground at play.rust-lang.org (opens in new tab) lets you write and run Rust in your web browser. Nothing to install.

  1. Open the page. You’ll see a small example program already there.
  2. Replace it with your own code.
  3. Click Run (top left). The output appears at the bottom.

The Playground is perfect for trying out the small examples in the next few lessons, or for testing an idea on a computer where you can’t install software. It also includes popular crates such as tokio and serde, so later examples that use them work there too. Later in the course we’ll build multi-file projects, and for those you’ll want Rust installed locally.

Try it yourself

  1. Run rustc --version and cargo --version and note your version numbers.
  2. Open the Rust Playground (opens in new tab), replace the code with the program below, and click Run.
src/main.rs
fn main() {
println!("Rusty Bean Café is open!");
}

Then change the message to announce today’s special (for example, a cinnamon latte) and run it again.

Show solution

Your version commands should print two lines that start with rustc and cargo. For the Playground part, your program might look like this:

src/main.rs
fn main() {
println!("Today's special at Rusty Bean Café: cinnamon latte!");
}

Output:

Output
Today's special at Rusty Bean Café: cinnamon latte!

Only the text between the double quotes changed. Everything else stays the same.

Recap

  • rustup installs and updates Rust. It gives you rustc (the compiler) and cargo (the project tool).
  • On macOS/Linux, install with the curl ... | sh command. On Windows, run rustup-init.exe.
  • Check your setup with rustc --version and cargo --version. If they aren’t found, open a fresh terminal.
  • VS Code plus the rust-analyzer extension gives you error highlighting, type hints and auto-complete.
  • The Rust Playground runs Rust in your browser with no install.

What’s next

Your kitchen is ready. In Hello World with Cargo you’ll create your first real Rust project for Rusty Bean Café and run it.

0 of 35 lessons complete

Search lessons

Type to search all lessons.