SyntaxStudy
Sign Up
Rust Installing Rust and Using Rustup
Rust Beginner 1 min read

Installing Rust and Using Rustup

Rust is installed and managed through rustup, the official toolchain installer. Running the one-line install script from rustup.rs sets up the stable toolchain, Cargo, the standard library sources, and cross-compilation support. Rustup makes it trivial to switch between the stable, beta, and nightly channels and to add compilation targets for different platforms. After installation, the `rustc` compiler and `cargo` build tool are available on your PATH. You can verify the installation with `rustc --version` and `cargo --version`. Rustup also installs `rustfmt` and `clippy` by default — tools that are deeply integrated into the Rust workflow and expected by most projects and CI pipelines. Keeping Rust up to date is as simple as running `rustup update`. Because Rust follows a six-week release cycle, new stable versions arrive frequently with new features, performance improvements, and bug fixes. The `rustup show` command lists all installed toolchains and the currently active one, while `rustup target add` lets you cross-compile for targets such as ARM microcontrollers or WebAssembly.
Example
# Install rustup and the stable toolchain (run in your terminal)
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Verify installation
# $ rustc --version
# rustc 1.78.0 (9b00956e5 2024-04-29)
# $ cargo --version
# cargo 1.78.0 (54d8815d0 2024-03-26)

# Update to the latest stable release
# $ rustup update

# Show installed toolchains
# $ rustup show

# Add a cross-compilation target (e.g. WebAssembly)
# $ rustup target add wasm32-unknown-unknown

# Add the nightly toolchain for experimental features
# $ rustup toolchain install nightly

# Compile a single file with rustc
# $ rustc main.rs -o hello && ./hello

// main.rs compiled above
fn main() {
    println!("Installed and running!");

    // rustc is the low-level compiler; for real projects use cargo
    let info = format!(
        "Arch: {}  OS: {}",
        std::env::consts::ARCH,
        std::env::consts::OS
    );
    println!("{info}");
}