Installing Rust

The first step to using Rust is to install it! There are a number of ways to install Rust, but the easiest is to use the rustup script. If we're on Linux or a Mac, all we need to do is this:

Note: we don't need to type in the $s, they are there to indicate the start of each command. We’ll see many tutorials and examples around the web that follow this convention: $ for commands run as our regular user, and # for commands we should be running as an administrator.

$ curl -sf -L https://static.rust-lang.org/rustup.sh | sh

If we're concerned about the potential insecurity of using curl | sh, please keep reading and see our disclaimer below. And feel free to use a two-step version of the installation and examine our installation script:

$ curl -f -L https://static.rust-lang.org/rustup.sh -O
$ sh rustup.sh

If you're on Windows, please download the appropriate installer.

Note: By default, the Windows installer won't add Rust to the %PATH% system variable. If this is the only version of Rust we are installing and we want to be able to run it from the command line, click on "Advanced" on the install dialog and on the "Product Features" page ensure "Add to PATH" is installed on the local hard drive.

Uninstalling

If you decide you don't want Rust anymore, we'll be a bit sad, but that's okay. Not every programming language is great for everyone. We can run the uninstall script:

$ sudo /usr/local/lib/rustlib/uninstall.sh

If we used the Windows installer, we can re-run the .msi and it will give us an uninstall option.

That disclaimer we promised

Some people, and somewhat rightfully so, get very upset when we tell them to curl | sh. Their concern is that curl | sh implicitly requires you to trust that the good people who maintain Rust aren't going to hack your computer and do bad things — and even having accepted that, there is still the possibility that the Rust website has been hacked and the rustup script compromised.

Being wary of such possibilities is a good instinct! If you're uncomfortable using curl | sh for reasons like these, please check out the documentation on building Rust from Source, or the official binary downloads.

Platform support

The Rust compiler runs on, and compiles to, a great number of platforms, though not all platforms are equally supported. Rust's support levels are organized into three tiers, each with a different set of guarantees.

Platforms are identified by their "target triple" which is the string to inform the compiler what kind of output should be produced. The columns below indicate whether the corresponding component works on the specified platform.

Tier 1

Tier 1 platforms can be thought of as "guaranteed to build and work". Specifically they will each satisfy the following requirements:

Target std rustc cargo notes
x86_64-pc-windows-msvc 64-bit MSVC (Windows 7+)
i686-pc-windows-gnu 32-bit MinGW (Windows 7+)
x86_64-pc-windows-gnu 64-bit MinGW (Windows 7+)
i686-apple-darwin 32-bit OSX (10.7+, Lion+)
x86_64-apple-darwin 64-bit OSX (10.7+, Lion+)
i686-unknown-linux-gnu 32-bit Linux (2.6.18+)
x86_64-unknown-linux-gnu 64-bit Linux (2.6.18+)

Tier 2

Tier 2 platforms can be thought of as "guaranteed to build". Automated tests are not run so it's not guaranteed to produce a working build, but platforms often work to quite a good degree and patches are always welcome! Specifically, these platforms are required to have each of the following:

Target std rustc cargo notes
i686-pc-windows-msvc 32-bit MSVC (Windows 7+)

Tier 3

Tier 3 platforms are those which Rust has support for, but landing changes is not gated on the platform either building or passing tests. Working builds for these platforms may be spotty as their reliability is often defined in terms of community contributions. Additionally, release artifacts and installers are not provided, but there may be community infrastructure producing these in unofficial locations.

Target std rustc cargo notes
x86_64-unknown-linux-musl 64-bit Linux with MUSL
arm-linux-androideabi ARM Android
i686-linux-android 32-bit x86 Android
aarch64-linux-android ARM64 Android
arm-unknown-linux-gnueabi ARM Linux (2.6.18+)
arm-unknown-linux-gnueabihf ARM Linux (2.6.18+)
aarch64-unknown-linux-gnu ARM64 Linux (2.6.18+)
mips-unknown-linux-gnu MIPS Linux (2.6.18+)
mipsel-unknown-linux-gnu MIPS (LE) Linux (2.6.18+)
powerpc-unknown-linux-gnu PowerPC Linux (2.6.18+)
i386-apple-ios 32-bit x86 iOS
x86_64-apple-ios 64-bit x86 iOS
armv7-apple-ios ARM iOS
armv7s-apple-ios ARM iOS
aarch64-apple-ios ARM64 iOS
i686-unknown-freebsd 32-bit FreeBSD
x86_64-unknown-freebsd 64-bit FreeBSD
x86_64-unknown-openbsd 64-bit OpenBSD
x86_64-unknown-netbsd 64-bit NetBSD
x86_64-unknown-bitrig 64-bit Bitrig
x86_64-unknown-dragonfly 64-bit DragonFlyBSD
x86_64-rumprun-netbsd 64-bit NetBSD Rump Kernel
i686-pc-windows-msvc (XP) Windows XP support
x86_64-pc-windows-msvc (XP) Windows XP support

Note that this table can be expanded over time, this isn't the exhaustive set of tier 3 platforms that will ever be!

After installation

If we've got Rust installed, we can open up a shell, and type this:

$ rustc --version

You should see the version number, commit hash, and commit date.

If you do, Rust has been installed successfully! Congrats!

If you don't and you're on Windows, check that Rust is in your %PATH% system variable. If it isn't, run the installer again, select "Change" on the "Change, repair, or remove installation" page and ensure "Add to PATH" is installed on the local hard drive.

This installer also installs a copy of the documentation locally, so we can read it offline. On UNIX systems, /usr/local/share/doc/rust is the location. On Windows, it's in a share/doc directory, inside the directory to which Rust was installed.

If not, there are a number of places where we can get help. The easiest is the #rust IRC channel on irc.mozilla.org, which we can access through Mibbit. Click that link, and we'll be chatting with other Rustaceans (a silly nickname we call ourselves) who can help us out. Other great resources include the user’s forum, and Stack Overflow.