Rust Tools & Setup: Everything You Need
When you start with Rust, you hear a lot of new names at once: rustup, rustc, cargo, clippy, rustfmt, rust-analyzer. It can feel like you need ten tools before you can write one line. The good news: one installer gives you almost all of them, and each tool has one clear job.
Think of it like a kitchen. rustup is the shop that delivers and replaces your equipment. cargo is the chef who runs everything. clippy is the friendly teacher looking over your shoulder, and rustfmt keeps the counter tidy. This page explains every tool, what you need on your operating system, and how a Rust developer uses them day to day.
If you haven’t installed Rust yet, the step-by-step install and your first project are on Get Started. The basics of cargo (cargo new, cargo add, Cargo.toml) are on Cargo & Crates. This page builds on both.
The big picture
Section titled “The big picture”Here is the whole toolbox in one table:
| Tool | What it does | Comes with rustup? |
|---|---|---|
rustup |
Installs Rust, updates it, and switches between versions | It is the installer |
rustc |
The compiler: turns your .rs files into a program |
Yes |
cargo |
Builds, runs, tests, and adds crates. You use it for almost everything | Yes |
rustup doc |
Opens the standard library docs and the Rust Book offline in your browser | Yes (default profile) |
clippy |
A linter: points out bugs and simpler ways to write your code | Yes (default profile) |
rustfmt |
A formatter: rewrites your code in the standard style | Yes (default profile) |
rust-analyzer |
The “editor brain”: autocompletion, inline errors, type hints, go to definition | Not by default. The VS Code extension brings its own copy |
| A debugger | Pause your program at a line and look at its variables | No. You install LLDB or GDB (or an editor extension that includes one) |
A profile is a group of components that rustup installs. The normal install uses the default profile, which adds docs, clippy and rustfmt on top of the compiler and cargo. If someone set up your machine with the minimal profile, cargo clippy will say it’s not installed. One command fixes that: rustup component add clippy rustfmt.
Try rustup doc --std once. It opens the full standard library documentation from your own disk, so it works on a plane or a slow connection. For the docs of your own project and every crate it uses, run cargo doc --open (more on that in Documentation).
Before you install: what each OS needs
Section titled “Before you install: what each OS needs”Rust compiles your code, but at the very end it needs a linker: a program that joins the compiled pieces into one file you can run. Rust uses the linker that your system’s C tools provide. That’s why each OS needs a small extra step.
| OS | What to install | How |
|---|---|---|
| Windows (recommended) | Visual Studio’s C++ tools: the MSVC linker and the Windows SDK | Pick the Desktop development with C++ workload in the Visual Studio installer |
| Windows (alternative) | The GNU toolchain (MinGW) | rustup toolchain install stable-gnu |
| Windows (another option) | WSL, a real Linux inside Windows | wsl --install, then follow the Linux steps |
| macOS | Apple’s command line tools (includes a C compiler and linker) | xcode-select --install |
| Debian / Ubuntu | A C compiler and linker | sudo apt install build-essential |
| Fedora | A C compiler and linker | sudo dnf install gcc |
A few honest notes:
- Windows and Visual Studio. You don’t need to find this yourself: if Visual Studio is missing,
rustup-init.exeoffers to install it for you. It installs Visual Studio Community, which is free for individuals, students and open source, but not for every company. If you install it at work, ask which edition your company uses. Selecting the “Desktop development with C++” workload gets everything Rust needs. - Windows and GNU. The MSVC toolchain is the default and works best with other Windows software. The GNU toolchain needs no Visual Studio for simple programs, but many crates that include C code won’t build until you also install MSYS2 with MinGW. Most people should stay with MSVC.
- WSL is a great choice if you want a Linux environment on Windows (for example, because your server runs Linux). Inside WSL, you install Rust with the normal Linux command, separately from any Windows install.
- Linux extras. Some popular crates talk to system libraries. If a build fails with a message about
pkg-configor OpenSSL, on Ubuntu installpkg-configandlibssl-devtoo.
After this, follow the install steps on Get Started.
rustup in practice
Section titled “rustup in practice”Once Rust is installed, rustup is the tool you use to look after it. A new stable Rust comes out every six weeks, so updating is a normal habit:
rustup update # update all installed toolchains (and rustup itself)rustup show # what's installed, and which toolchain is active hererustup show prints something like this (trimmed):
Default host: x86_64-unknown-linux-gnu
installed toolchains--------------------stable-x86_64-unknown-linux-gnu (active, default)
active toolchain----------------name: stable-x86_64-unknown-linux-gnuactive because: it's the default toolchainStable, beta and nightly
Section titled “Stable, beta and nightly”A toolchain is one complete set of rustc, cargo and friends. Rust has three release channels:
| Channel | What it is | Use it when |
|---|---|---|
| stable | The official release, every six weeks | Almost always. This is what you want |
| beta | The next stable release, being tested | You want to check your project before the next release |
| nightly | Built every night, with experimental features | A tool or crate asks for it, or you want to try a new feature |
You can have several toolchains installed side by side:
rustup toolchain install nightly # install nightly next to stablecargo +nightly build # use nightly for this one commandrustup default stable # choose which toolchain is used everywherePinning a toolchain per project
Section titled “Pinning a toolchain per project”Sometimes a project needs a specific Rust version. Put a file called rust-toolchain.toml in the project folder and rustup switches automatically whenever you work in that folder:
[toolchain]channel = "1.97.0"components = ["clippy", "rustfmt"]targets = ["wasm32-unknown-unknown"]Commit this file to git. Then everyone on your team (and your CI) uses exactly the same compiler, and rustup installs it for them if it’s missing. Most small projects don’t need this file at all; they just use the latest stable.
Components and targets
Section titled “Components and targets”Components are extra pieces of a toolchain. Targets let you compile for a different kind of machine:
rustup component add clippy rustfmt rust-src # rust-src: std source code, used by rust-analyzerrustup component list --installed # see what you haverustup target add wasm32-unknown-unknown # compile Rust for the browserThe wasm32-unknown-unknown target is what you need for WebAssembly.
Editors and IDEs
Section titled “Editors and IDEs”You can write Rust in any text editor, but an editor with rust-analyzer (or a similar engine) makes a huge difference. You see errors as you type, the types of your variables appear next to them, and you can jump to any function’s definition. For a beginner, that feedback is like having a patient tutor.
| Editor | Price | Rust support | Good for |
|---|---|---|---|
| VS Code + rust-analyzer | Free | Official rust-analyzer extension | Most people. It’s the most popular choice, and most guides assume it |
| RustRover (JetBrains) | Free for non-commercial use (learning, hobby projects, unpaid open source). Commercial work needs a paid subscription | Built in, with JetBrains’ own Rust engine and a built-in debugger | People who like a full IDE with everything included |
| Zed | Free, open source | Built in (uses rust-analyzer, and CodeLLDB for debugging) | A very fast, modern editor |
| Neovim / Helix | Free, open source | Through rust-analyzer. Helix works almost out of the box; Neovim needs a little config | People who love working in the terminal |
| Visual Studio | Paid editions, plus free Community | No official Rust support | Not a good fit for Rust. You only need its C++ Build Tools for the linker |
RustRover’s licence terms can change, so check the RustRover page for the current rules before you use it at work.
For Neovim, Helix and other editors, install the rust-analyzer program itself with rustup component add rust-analyzer.
Recommended VS Code extensions
Section titled “Recommended VS Code extensions”If you use VS Code, these four cover nearly everything:
- rust-analyzer — the essential one: completion, errors, hints, refactoring.
- CodeLLDB — a debugger for breakpoints and stepping through code. It includes its own copy of LLDB.
- Even Better TOML — colors and checks your
Cargo.toml. - Error Lens (optional) — shows error messages right on the line, not only when you hover. Some people love it, some find it noisy.
Debugging
Section titled “Debugging”Breakpoints with CodeLLDB
Section titled “Breakpoints with CodeLLDB”With rust-analyzer and CodeLLDB installed in VS Code, you’ll see small Run | Debug links above fn main and above every test. Click a line number’s left edge to set a red breakpoint dot, then click Debug. The program stops at your breakpoint, and you can look at every variable and step through the code line by line.
If you want a reusable setup (for example, to pass command-line arguments), create .vscode/launch.json:
{ "version": "0.2.0", "configurations": [ { "type": "lldb", "request": "launch", "name": "Debug task_queue", "cargo": { "args": ["build", "--bin=task_queue"] }, "args": [], "cwd": "${workspaceFolder}" } ]}The cargo part tells CodeLLDB to build your program with cargo first, then start it in the debugger. Replace task_queue with your package name, and put any program arguments in "args". Press F5 to start.
Quick checks with dbg!
Section titled “Quick checks with dbg!”You don’t always need a full debugger. The dbg! macro prints an expression, its value, and the file and line where you wrote it. It also gives the value back, so you can wrap it around almost anything without changing what your code does:
fn apply_discount(price: u32, percent: u32) -> u32 { price - price * percent / 100}
fn main() { let prices = [120, 45, 80];
let total: u32 = dbg!(prices.iter().sum()); let final_price = dbg!(apply_discount(total, 10));
println!("Total after a 10% discount: {final_price}");}Output:
Total after a 10% discount: 221Where did the dbg! lines go? dbg! prints to stderr (the error stream), not to stdout like println!. That keeps your debug notes apart from your real output. In your terminal, or in the Playground’s “Standard Error” section, you’ll also see:
[src/main.rs:8:22] prices.iter().sum() = 245[src/main.rs:9:23] apply_discount(total, 10) = 221Remove your dbg! calls when you’re done. They’re for you, not for your users.
Code quality every day
Section titled “Code quality every day”Three commands keep your code healthy. They’re fast, so run them often.
cargo check: fast feedback
Section titled “cargo check: fast feedback”cargo check finds compile errors without building a program to run, so it’s much faster than cargo build. Many developers run it every few minutes. (Your editor’s rust-analyzer runs a check like this for you every time you save.)
cargo fmt: never argue about style
Section titled “cargo fmt: never argue about style”cargo fmt rewrites every file in your project in the standard Rust style. Nobody on your team has to think about spaces or line breaks again. It turns this:
struct Player{name:String,score:u32}fn top(players:&[Player])->Option<&Player>{players.iter().max_by_key(|p|p.score)}into this:
struct Player { name: String, score: u32,}fn top(players: &[Player]) -> Option<&Player> { players.iter().max_by_key(|p| p.score)}Most editors can run it every time you save. In VS Code, turn on the “Format On Save” setting.
cargo clippy: a friendly code review
Section titled “cargo clippy: a friendly code review”Clippy knows hundreds of patterns that are wrong, slow, or simply harder to read than they need to be. Here is a small program that works fine:
fn main() { let tasks: Vec<&str> = vec!["write docs", "fix bug"];
if tasks.len() == 0 { println!("Nothing to do!"); } else { println!("{} tasks waiting", tasks.len()); }}But cargo clippy has a suggestion:
warning: length comparison to zero --> src/main.rs:4:8 |4 | if tasks.len() == 0 { | ^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `tasks.is_empty()` | = note: `#[warn(clippy::len_zero)]` on by defaultEvery warning has a name (here len_zero) that you can look up in the Clippy lint list for a longer explanation. Here’s the fixed version:
fn main() { let tasks: Vec<&str> = vec!["write docs", "fix bug"];
if tasks.is_empty() { println!("Nothing to do!"); } else { println!("{} tasks waiting", tasks.len()); }}Output:
2 tasks waitingcargo clippy --fix can apply many suggestions for you. Clippy is not always right for your situation, but it’s right often enough that reading every warning is a fast way to learn idiomatic Rust.
Useful extra cargo tools
Section titled “Useful extra cargo tools”Anyone can add new cargo subcommands. You install them with cargo install, which downloads the source, compiles it, and puts the program in ~/.cargo/bin (on Windows, %USERPROFILE%\.cargo\bin). You don’t need any of these on day one, but they’re worth knowing:
| Tool | What it does | Install | Run |
|---|---|---|---|
| bacon | Re-runs check, clippy or tests every time you save, in a side terminal | cargo install --locked bacon |
bacon, bacon clippy, bacon test |
| cargo-watch | Runs any cargo command on save. Still works, but no longer updated; its author recommends bacon | cargo install --locked cargo-watch |
cargo watch -x check |
| cargo-nextest | A faster test runner with clearer output | cargo install --locked cargo-nextest |
cargo nextest run |
| cargo-audit | Checks your Cargo.lock against known security advisories |
cargo install cargo-audit |
cargo audit |
| cargo-outdated | Lists dependencies that have newer versions | cargo install --locked cargo-outdated |
cargo outdated |
| cargo-edit | Adds cargo upgrade, which raises versions in Cargo.toml (cargo add is already built in) |
cargo install cargo-edit |
cargo upgrade |
| cargo-expand | Shows the code that your macros and #[derive]s turn into |
cargo install cargo-expand |
cargo expand |
| cargo-binstall | Downloads ready-made binaries instead of compiling, so installs take seconds | cargo install cargo-binstall |
cargo binstall bacon |
cargo install compiles from source, so the first install of a big tool can take a few minutes. That’s normal. To update a tool later, run the same install command again. To see what you’ve installed, run cargo install --list. For speed-focused tools like profilers and benchmarks, see Performance.
No install at all: the Rust Playground
Section titled “No install at all: the Rust Playground”The Rust Playground runs Rust in your browser. Every “Try it Yourself” button on this site opens it. It’s perfect for quick experiments, sharing a snippet when you ask for help, or learning on a computer where you can’t install anything.
What it can do:
- Run your code on stable, beta or nightly, as a debug or release build.
- Use the 100 most downloaded crates from crates.io (plus the crates used by the Rust Cookbook, and their dependencies), such as
serde,rand,regexandtokio. - Run
rustfmtand Clippy from the Tools menu. - Share your code as a link.
What it can’t do:
- Have more than one file. There’s no
Cargo.toml, so you can’t pick other crates or versions. - Reach the network. Code that downloads a web page will fail.
- Work with your own files, or run for a long time. Time and memory are limited.
- Be comfortable for interactive programs. While a program runs, a small box lets you type input, but that’s awkward for anything more than a quick test. The examples on this site never read input, so they run with one click.
When you outgrow it, a local project with cargo new is only a minute away.
A starter checklist for a new machine
Section titled “A starter checklist for a new machine”Setting up a new computer? Go through this list once:
- Install your OS prerequisites: the Visual Studio C++ tools (Windows),
xcode-select --install(macOS), orbuild-essential/gcc(Linux). - Install Rust from rustup.rs, then open a new terminal.
- Check it:
rustc --versionandcargo --version. - Make sure the everyday tools are there:
rustup component add clippy rustfmt. - Install an editor with rust-analyzer. With VS Code, add the rust-analyzer and CodeLLDB extensions.
- Turn on format on save in your editor.
- Create a test project with
cargo new helloand runcargo run,cargo clippyandcargo fmtin it. - Set a reminder to run
rustup updateevery month or two. - Optional:
cargo install --locked baconfor instant feedback while you code.
Practice
Section titled “Practice”1. Check your toolbox
Section titled “1. Check your toolbox”On your own machine, run each of these commands and make sure none of them says “not installed”: rustup show, cargo clippy --version, cargo fmt --version. Then open the offline standard library docs and find the page for Vec. Hint: rustup doc takes a topic, like a type’s full path.
Show solution
rustup showcargo clippy --versioncargo fmt --versionrustup doc std::vec::VecEach --version command prints a version number. If one prints an error instead, install the missing piece with rustup component add clippy or rustup component add rustfmt. The last command opens the Vec page in your browser, straight from your disk. If it says rust-docs is not installed, run rustup component add rust-docs first.
2. Let Clippy teach you
Section titled “2. Let Clippy teach you”In a new project, paste the first version of the task program from the Clippy section into src/main.rs. Run cargo clippy, read the warning, then let Clippy fix it for you. Hint: there’s a flag that applies the suggestions automatically.
Show solution
cargo new task_queuecd task_queue# paste the program into src/main.rs, then:cargo clippycargo clippy --fix --allow-dirtycargo clippyThe first cargo clippy shows the len_zero warning. cargo clippy --fix rewrites tasks.len() == 0 into tasks.is_empty(). The --allow-dirty flag lets it change files you haven’t committed to git yet. The last run prints no warnings.
- rustup installs and updates Rust and switches toolchains; cargo builds, runs, tests and adds crates; rustc is the compiler underneath.
- Each OS needs a linker first: Visual Studio’s C++ tools on Windows,
xcode-select --installon macOS,build-essentialorgccon Linux. - Stay on stable. Use
rust-toolchain.tomlonly when a project must pin a version, andcargo +nightlyfor one-off nightly commands. - Use an editor with rust-analyzer. VS Code with rust-analyzer and CodeLLDB is the most common setup.
- Run
cargo checkoften, andcargo fmtpluscargo clippybefore every commit. Usedbg!for quick looks and a debugger for harder bugs. - The Playground is great for experiments and sharing, but it’s one file, no network, and only the most popular crates.
Quick check
Section titled “Quick check”Quick check
1. Which tool would you use to install the nightly toolchain next to stable?
2. Your Windows build fails because no linker is found. What is missing most likely?
3. Where does dbg! print its output?
4. Which of these can the Rust Playground NOT do?
Score: 0 / 4
Read more
Section titled “Read more”- Install Rust — rust-lang.org: the official installer for every platform, plus notes on Windows,
PATHand uninstalling. - The rustup book: toolchains, channels, components, profiles,
rust-toolchain.tomland cross-compilation targets. - The Cargo Book: everything about cargo, including
cargo installand every command’s options. - rust-analyzer manual: setting up rust-analyzer in VS Code, Neovim, Helix, Emacs and more, and all its settings.
- Clippy documentation: how to run and configure Clippy, with a link to the full list of lints and what each one means.