Rust Installation
Rust installation is the setup that puts the Rust compiler on a computer. The tool rustup manages the installation.
Check that it worked
rustup installs Rust and brings rustc (the compiler) and Cargo (the project tool) in one go. Afterwards, ask the compiler its version:
# in your terminal:
# $ rustc --version
# (it prints your compiler version, like rustc 1.85.0)Update at any time
One command brings the newest stable Rust:
# in your terminal:
# $ rustup updateRust also needs a linker
A linker joins the pieces the compiler makes into one file: the finished program. Most computers get one with a C compiler:
# macOS: xcode-select --install
# Ubuntu: install the build-essential package
# Windows: the Visual Studio installer offers the C toolsRead the manuals offline
Rust installs a local copy of its books and manuals — no internet needed:
# in your terminal:
# $ rustup docRemove everything
One command uninstalls Rust completely:
# in your terminal:
# $ rustup self uninstallExample
fn main() {
let tool = "rustc";
println!("{} compiled this program", tool);
}Key points
- No install yet?
- The Rust Playground at play.rust-lang.org runs small Rust programs in your browser.
- Every example in the first lessons of this course fits there.
- Most learners write Rust in an editor with the rust-analyzer extension.
- It underlines mistakes as you type.
- It explains them before you even run the program.
- The commands run in a terminal, the text-only window for typing commands.
In this example, one check comes before the program: run rustc --version in your terminal once, after installing. If a version prints, Rust is ready. The program itself is tiny. The word rustc is saved in the variable tool. Then println! fills the {} slot with tool, so the line reads: rustc compiled this program. Your own version number will differ from the comment. That is fine. Any recent stable version runs every lesson in this course.
Note
Rust promises stability: code that compiles today will still compile on next year's compiler.
Updating is safe and boring — that is the point.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
Which tool installs Rust and keeps it up to date?