Installing Rust on Windows

Mehul Patel
3 min readJun 20, 2017

--

Installing Rust can be as easy as pulling down an installer and double clicking. For developers working with more complex tools or who need to build unsafe C/C++ libraries from source, there’s a little bit of extra work that needs to be done, but it’s nothing that a savvy person can’t handle.

Throughout this whole process, make sure you keep installing the right version of libraries — Rust is currently 64-bit only for MSVC. You’ll get bizarro errors at various points if you mess up and try to use 32-bit libraries or prereqs with Rust. Trust me.

Again — if all you need is a Rust compiler, jump over to https://www.rust-lang.org/ and click “Install”. If you plan on working with natively compiled C/C++ libraries, then read on!

Why Do I Need A C Compiler for Rust?

You might need a C/C++ compiler if you’re going to be using libraries that were written in C or C++. For instance — if you’re using a web library like hyper, which uses OpenSSL by default, you’ll need to link to the OpenSSL library on your system.

OK, I Don’t Need a C Compiler. Now What?

Well, just pick a Rust binary and download it. I prefer the Rust MSVC version, but that’s just me. If you’re using rustup.rs, then it isn’t hard to change which Rust toolchain you’re using.

After you’ve installed your rust compiler, you’re done. There’s nothing more to it that than. Just have fun writing code. You can skip down to Additional Rust Tools to get more of your environment set up.

I Think I Need a C Compiler

If you think you might be linking to native libraries, then you’ll want to go ahead and install one. Sure, it takes up disk space and takes some time up front, but it will save you some time and frustration later on if you already have your compiler ready to go when you need it.

Let’s install Rust on Windows

Rustup

Rustup is a tool for managing multiple Rust installations in the same OS. This makes it possible to use different versions of Rust for different projects or to even evaluate the nightly version of Rust to check out new features!

Right now, head over to the rustup.rs and get the current Windows installer. Once it downloads, double click and wait. Once that finishes, open up a brand new terminal and run rustup default stable-x86_64-stable.

We need to double check that an environment variable got set. I’m assuming you know how to find these. Once you’ve found your environment variables, check the PATH to see if ~/.cargo/bin has been added to your path. I use ~ as an abbreviation for your home folder. On my computer, I’m looking to see if C:\Users\Rowdy\.cargo\bin is on the PATH. If it’s not there, add it.

Additional Rust Tools

At this point, we’ve got a working Rust installation. We could get started with rustc and cargo and create software. But, there are some additional tools we can install to make our environment a bit nicer.

Racer

RACER = Rust Auto-Complete-er. A utility intended to provide Rust code completion for editors and IDEs. If you’ve put .cargo\bin in your PATH and you’ve got the RUST_SRC_PATH environment variable set up, installing Racer is easy. Just run cargo install racer and wait for it to install.

rustfmt

rustfmt is a tool to find and fix Rust formatting issues.

cargo install rustfmt

DONE!

Hope you enjoyed my blog. Don’t Forget To Share It With Your All Tech Friends..!! :)

Originally published at Rowdy’s Caf`e.

--

--

Mehul Patel

Tech Speaker | Linux Engineer | DevOps | OpenSource Enthusiast | Independent Researcher | Technical Writer | Explorer