Install Rust on Linux, macOS and Windows
Install Rust the official way with rustup, which brings rustc, cargo and future updates, make sure a C linker is present, and verify with cargo new.
Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?
Which option to pick
The Rust project recommends rustup on every platform, and in practice everyone uses it: it installs the compiler rustc, the build tool and package manager cargo, documentation and other components into your home directory, keeps them updated with one command, and can hold several toolchains (stable, beta, nightly) side by side. Distribution packages such as apt install rustc exist but are frozen at release time, and Rust projects move quickly. The only extra requirement is a system linker: a C compiler toolchain on Linux and macOS, or the Microsoft C++ build tools on Windows.
Step: Linux
Install a C toolchain first, then rustup:
Check before you run this
- Downloads a file and runs it straight away. Open the URL and read the script first.
- Runs with administrator rights. Make sure you understand every line.
sudo apt install build-essential
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"
On Fedora the first line is sudo dnf install gcc, on Arch sudo pacman -S base-devel. The rustup script asks a question; the default option 1 installs the stable toolchain and adds ~/.cargo/bin to your PATH through your shell startup files. The final line applies that to the current shell.
Step: macOS
Check before you run this
- Downloads a file and runs it straight away. Open the URL and read the script first.
xcode-select --install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"
The command line tools provide the linker. brew install rustup is an alternative way to get rustup itself; after it, run rustup-init once. Avoid brew install rust, which installs a fixed toolchain without rustup.
Step: Windows
winget install Rustlang.Rustup
Or download and run rustup-init.exe from rustup.rs. The installer checks for the Visual Studio C++ build tools and offers to install them if they are missing; accept, because the default Windows toolchain (x86_64-pc-windows-msvc) needs Microsoft’s linker. This download is large. Afterwards, open a new terminal so cargo is on PATH.
Check it works
rustc --version
cargo --version
rustup --version
Then create, build and run a project to confirm the linker works as well as the compiler:
cargo new hello-rust
cd hello-rust
cargo run
The output ends with Hello, world!. Later, update everything with rustup update, and open the offline documentation with rustup doc.
Common problems
error: linker `cc` not foundon Linux: install the C toolchain (build-essentialorgcc) and build again.cargo: command not foundin a new terminal: the startup file was not updated or is not the one your shell reads. Add. "$HOME/.cargo/env"to~/.bashrcor~/.zshrc.- Windows:
error: linker `link.exe` not found: the Visual Studio C++ build tools are missing. Re-run the Visual Studio Installer and add the Desktop development with C++ workload, or switch to the GNU toolchain withrustup default stable-x86_64-pc-windows-gnu. - Builds fail after a long time with a crate needing a newer compiler: run
rustup update; projects can also pin their version in arust-toolchain.tomlfile, which rustup honours automatically.
Official documentation
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0386 Install Node.js on Linux, macOS and Windows Get Node.js and npm on any desktop OS. Use a version manager (nvm or fnm) when you work on several projects, or… Beginner · Step by step · Linux, macOS, Windows Article Installing languages & tools · Node.js 15 Oct 2026
- 0387 Install Python on Linux, macOS and Windows Install a current Python 3 with pip and venv on each desktop OS, check the version, and avoid the classic traps: python… Beginner · Step by step · Linux, macOS, Windows Article Environments & packages · Installing languages & tools 15 Oct 2026
- 0388 Install Go on Linux, macOS and Windows Install the Go toolchain from the official downloads or a package manager, set PATH so the go command and installed tools are… Beginner · Step by step · Linux, macOS, Windows Article Installing languages & tools 15 Oct 2026
- 0389 Install Java (OpenJDK) on Linux, macOS and Windows Install a current long-term-support OpenJDK with the compiler included, make java and javac available on the command line, and switch between versions… Beginner · Step by step · Linux, macOS, Windows Article Installing languages & tools 15 Oct 2026
- 0390 Install Git on Linux, macOS and Windows Install Git from your package manager, Xcode's command line tools or the Windows installer, confirm the version, and do the one-time configuration… Beginner · Step by step · Linux, macOS, Windows Article Installing languages & tools · Setup 15 Oct 2026
- 0391 Install Docker on Linux, macOS and Windows Docker Desktop or Docker Engine? Pick the right one for your OS, install it, and confirm with docker run hello-world. Covers the… Beginner · Step by step · Linux, macOS, Windows Article Docker basics · Installing languages & tools 15 Oct 2026
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Dominik +3,045 chars