Installing Rust with Rustup
In this page:
Installing Rustup
Rustup is the official way to install and manage Rust versions. On Linux and macOS, you run a single shell command that downloads and runs the rustup installer, which then installs the rustc compiler, the cargo build tool, and the standard library.
Note: After the installer finishes, open a new terminal or run source $HOME/.cargo/env so the new commands are on your PATH.
Example: Installing Rustup
# Linux/macOS
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Windows
# Download and run rustup-init.exe from https://rustup.rs
⚠️ Run this command in your terminal.
Checking the Installed Version
Once installed, you can confirm Rust is ready by asking the compiler and the Cargo build tool for their version numbers. This is the fastest way to verify the install worked before writing any code.
Example: Checking the Installed Version
rustc --version
cargo --version
⚠️ Run this command in your terminal.
Updating Rust
Rust ships new stable releases roughly every six weeks. rustup update fetches the latest stable toolchain so you always have current compiler features and standard library additions.
Example: Updating Rust
rustup update stable
⚠️ Run this command in your terminal.
Confirming From Inside a Program
You can also verify your toolchain works end-to-end by compiling and running an actual Rust program. If it prints correctly, your installation is complete and functional.
Example: Confirming From Inside a Program
fn main() {
println!("Rust toolchain is installed and working!");
}
Login to try C/C++/Java/PHP code in the editor
- Trying to install Rust through a system package manager and ending up with an old version instead of using rustup.
- Forgetting to restart the terminal (or reload the shell profile) so the
cargoandrustccommands are not found. - Not running
rustup updateperiodically, which leaves you on an old compiler missing newer language features.
- Rustup is the official installer and version manager for Rust, covering rustc, cargo, and standard tooling.
- On Linux/macOS you install it by running a shell script from rust-lang.org; on Windows there is a dedicated installer.
rustup updatekeeps your toolchain current, andrustup showdisplays what is installed.- After installation,
rustc --versionandcargo --versionconfirm everything is working.
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: