Part 01 · Rust Is Not Scary
Set Up Rust in 10 Minutes
Install Rust with one command, set up your editor, and run code in the browser when you just want to try something.
⏱ 15 min · Station 1 of 75
Goal
By the end of these ten minutes you will have Rust installed, an editor that understands Rust, and a first project that compiles and runs. You will also know where to go when you only want to try three lines of code without creating anything.
Three tools, one job each:
- rustup installs Rust and keeps it up to date. Think of it as the shop that sells you the toolbox.
- rustc is the compiler. It turns your
.rsfiles into a program your computer can run. - cargo is the tool you actually type every day. It creates projects, calls
rustcfor you, downloads libraries and runs tests. You will almost never callrustcby hand.
Everything below was run on Ubuntu 26.04 with Rust 1.98.1. Newer versions print the same thing with a different number.
Setup
Linux and macOS
One command. It downloads rustup, which then installs the latest stable Rust into your home folder (no sudo needed):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Press Enter to accept the default install. When it finishes, open a new terminal (or run source "$HOME/.cargo/env") so your shell can find the new commands.
Rust needs a linker from a C toolchain to produce the final program. Most Macs already have it once you run xcode-select --install. On Ubuntu or Debian install it once:
sudo apt install build-essential
Windows
Download rustup-init.exe from rustup.rs and run it. It will ask for the Visual Studio C++ Build Tools (the Windows linker); let it install them. Then open a new PowerShell window.
Check it worked
rustc --version
cargo --version
rustup --version
rustc 1.98.1 (48a229cea 2026-09-01)
cargo 1.98.1 (797e8a9bc 2026-08-05)
rustup 1.29.1 (d95a37b6a 2026-08-13)
Three version lines means everything is in place. Later, rustup update moves you to the newest stable Rust in one step. A new stable version comes out every six weeks, and old code keeps compiling.
Your editor
Use VS Code (or any editor that speaks the Language Server Protocol) with the rust-analyzer extension, ID rust-lang.rust-analyzer. It is the official Rust language server. It gives you:
- red squiggles for compiler errors while you type, before you even run anything,
- the type of every variable shown in grey next to it (very useful while you learn),
- go to definition, rename, and auto-import.
If your editor shows type hints like : i32 next to your variables, rust-analyzer is working.
Just want to try something? Use the Playground
play.rust-lang.org runs Rust in your browser. No install, nothing to set up. Paste code, press Run, read the output. It is perfect for the small examples in these lessons, and for sharing a snippet with someone when you are stuck.
Walkthrough
Create a project and run it. cargo new makes the folder and the files, cargo run compiles and runs:
cargo new hello-rust
cd hello-rust
cargo run
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
Compiling hello-rust v0.1.0 (/home/you/rust-lab/hello-rust)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.13s
Running `target/debug/hello-rust`
Hello, world!
Cargo made this layout for you:
hello-rust/
├── Cargo.toml # the project's name, version and libraries
├── Cargo.lock # exact versions of libraries (created on first build)
├── src/
│ └── main.rs # your code starts here
└── target/ # build output, safe to delete
And src/main.rs already has a working program in it:
fn main() {
println!("Hello, world!");
}
Now run it a second time without changing anything.
You run cargo run again without touching any file. What happens?
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/hello-rust`
Hello, world!
No Compiling line this time, and 0.01s instead of 0.13s. Cargo only rebuilds what changed.
Reading the output
Each line cargo printed means something:
Creating binary (application) package: cargo made a project that builds a program you can run (a binary). The other kind, a library, is code other projects use; you would get that withcargo new --lib.Compiling hello-rust v0.1.0 (...): cargo calledrustcon your code. The name and version come fromCargo.toml.Finished `dev` profile [unoptimized + debuginfo]: this is a debug build. It compiles quickly and keeps extra information for debuggers, but it is not optimized. For the real, fast version you runcargo build --release; you will see the difference in What Rust Is Good For.Running `target/debug/hello-rust`: the finished program lives at that path. You can run it directly with./target/debug/hello-rust, it does not need cargo or Rust installed to run.Hello, world!: that is the only line your program printed. Everything above it came from cargo.
First cargo run | Second cargo run | |
|---|---|---|
| Compiles? | yes | no, nothing changed |
| Time | 0.13 s | 0.01 s |
| Program output | Hello, world! | Hello, world! |
Troubleshoot
error: linker `cc` not found
This is the most common first-day problem on Linux. Rust compiled your code, but the last step (joining it into one program) needs a C linker that is not installed. Here is what it looks like:
Compiling hello-rust v0.1.0 (/home/you/rust-lab/hello-rust)
error: linker `cc` not found
|
= note: No such file or directory (os error 2)
error: could not compile `hello-rust` (bin "hello-rust") due to 1 previous error
Fix: sudo apt install build-essential (Ubuntu/Debian), sudo dnf install gcc (Fedora), or xcode-select --install (macOS). On Windows, rerun rustup-init.exe and let it install the Visual Studio Build Tools.
cargo: command not found
The install worked but your shell does not know about ~/.cargo/bin yet. Open a new terminal, or run source "$HOME/.cargo/env". If it still fails, check that ~/.cargo/bin is on your PATH.
rust-analyzer shows nothing, or says "failed to discover workspace"
Open the project folder (the one that contains Cargo.toml), not a parent folder or a single file. rust-analyzer finds projects through Cargo.toml.
The first build is slow
The first build of a project compiles everything once; later builds only redo what changed. When you add libraries in later parts, the first build downloads and compiles them too. That is normal and happens once.
Takeaway
rustup installs and updates Rust, cargo is the command you use every day, and rust-analyzer gives your editor the compiler's eyes while you type. cargo new and cargo run are all you need to start, and the Playground is there when you only want to try an idea. Next: why Rust has a reputation for being hard, and why that reputation is mostly about when it tells you things.
Station stamp
Finish the chapter
Done reading? Press Complete to save your progress. XP is Pro-only — on Pro this chapter is worth +15 XP.
Go Pro to earn XP →