danirod

Installing Rust via Rustup

Rustup recently reached v1.0.0. Rustup is a toolchain installer and manager, allowing to install multiple toolchains: stable, beta, nightly, or a particular version. It is very easy and convenient instead of other solutions that rely on manually installing packages. It just became a core project of Rust as well. The download page at Rust website has been updated to reflect this. In fact, Multirust, a similar project for managing multiple Rust installations, is now deprecated.

So, how do you install Rust via rustup? Their website points you to a oneliner that you can run on your terminal. I have quickly read the shell script and it seems that it detects your operating system and processor before downloading the appropiate rustup-init bootstrap script. For those who dislike oneliners (you have your point, anyway) or for those using Windows, you can manually get rustup-init or rustup-init.exe and execute it.

Once installed, Rustup will download the toolchains at ~/.rustup and place the active toolchain at ~/.cargo as usual. In order to activate the toolchain, the file ~/.cargo/env should be sourced. This will be done automatically after the terminal is restarted as it appends so to the ~/.profile file, but you can manually source the file to have Rust tools in your PATH without having to restart the shell. Once done, cargo, rustc and the other binaries will be in your PATH.

By the way, Rustup can manage the Rust standard library source code as well, which is useful, as an example, when using Racer. To get Rust source code, run rustup component add rust-src. Then, proceed to install Racer as usual. The location for the source code that should be used as $RUST_SRC_PATH is:

~/.rustup/toolchains/$TOOLCHAIN/lib/rustlib/src/rust/src

where $TOOLCHAIN is the toolchain you are using, such as stable-x86_64-apple-darwin or nightly-arm-unknown-linux-gnueabi.