# Rust Rust is a low-level and very performant programming language. ## Installation On every platform, the recommended approach is to use [[rustup]], the official Rust toolchain installer. It installs `rustc`, [[Cargo (Rust)|Cargo]], and the standard library, manages release channels (stable, beta, nightly), and lets you add components like `rust-analyzer`, `rustfmt`, and `clippy`. After installation on any platform, restart your shell so `~/.cargo/bin` (or `%USERPROFILE%\.cargo\bin` on Windows) is on `PATH`, then verify with: ```bash rustc --version cargo --version rustup show ``` ### Linux The one-liner from the official source. It downloads `rustup-init` and runs the interactive installer: ```bash curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh ``` You need a working C linker first. Install with your package manager: - Debian / Ubuntu: `sudo apt install build-essential` - Fedora: `sudo dnf groupinstall "Development Tools"` - Arch: `sudo pacman -S base-devel` Avoid distro packages (`apt install rustc`); they lag behind and don't manage channels. ### WSL [[Windows Subsystem for Linux (WSL)]] is just Linux, so the Linux install applies as-is *inside* the WSL distro: ```bash curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh ``` Important: install Rust separately on the Windows host and inside WSL if you need both. The toolchains are not shared. Editing on the Windows side and compiling in WSL via VSCode's Remote-WSL is the typical setup. ### macOS Same one-liner as Linux: ```bash curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh ``` You need the Xcode Command Line Tools for the linker. If `xcode-select -p` returns nothing, install them: ```bash xcode-select --install ``` [[Homebrew]] also offers `brew install rustup-init` (then run `rustup-init`). Avoid `brew install rust`; it pins a single version and conflicts with `rustup`. ### Windows Two paths. See [[How to install Rust on Windows]] for full details. Quick path with [[Winget]]: ```powershell winget install --id Rustlang.Rustup rustup default stable-msvc rustup update ``` Pre-requisite: the MSVC build tools must be installed first (Visual Studio with the *Desktop development with C++* workload, or the standalone Visual Studio Build Tools). Otherwise `rustc` cannot link. ### Recommended components After install, on any platform: ```bash rustup component add rust-analyzer rustfmt clippy ``` ## References - Official website: https://www.rust-lang.org/ - Blog: https://blog.rust-lang.org/ - Documentation - https://www.rust-lang.org/learn - Rust by example: https://doc.rust-lang.org/rust-by-example/ - Book: https://doc.rust-lang.org/book/ - Installation - Official install page: https://www.rust-lang.org/tools/install - rustup site: https://rustup.rs/ - rustup user guide: https://rust-lang.github.io/rustup/ - Windows MSVC pre-requisites: https://rust-lang.github.io/rustup/installation/windows-msvc.html - Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021 - Community: https://www.rust-lang.org/community - Source code: https://github.com/rust-lang - Useful [[Visual Studio Code (VSCode)]] extensions - rust-analyzer: https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer - CodeLLDB: https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb ## Related - [[rustup]] - [[Cargo (Rust)]] - [[How to install Rust on Windows]] - [[Windows Subsystem for Linux (WSL)]] - [[Homebrew]] - [[Winget]] - [[Visual Studio Code (VSCode)]]