Skip to content


Installing Rust in a custom location on Windows

It’s actually pretty well described in Rust’s documentation. I’m just putting it here because the documentation is large and I appear to have a hard time finding those specific instructions in a timely manner every time I need them.

First, you could grab a GUI installer from there, but Visual Studio Code doesn’t seem to like it much. And I also remember having some issues running rustup in that context.
This is why I rapidly decided to use the “recommended” rustup-init.exe.

Before running said rustup-init.exe:
1) Set the CARGO_HOME environment variable to where you want cargo to be. I picked D:\PROG\PROGRAMMING\Rust\cargo. (NB: for a convenient way to edit environment variables, I recommend Rapid Environment Editor)
2) Set the RUSTUP_HOME environment variable to where you want cargo to be. I picked D:\PROG\PROGRAMMING\Rust\rustup (I’m so creative, I know).
3) If you’re using Rapid Environment Editor, make sure you SAVE (until you do, the environment variables that you created/modified/deleted/etc are NOT actually changed)
4) Make sure you start a new console to run rustup-init.exe. If you use a console that was already running before you added the environment variables, that console won’t have them. If by any chance you are using ConEmu, you need to close and reopen the whole ConEmu: just opening a new tab won’t do, if ConEmu was already running before you add the variables. I insist on this point, because rustup-init.exe will give you NO warning/notification as to where the install will be performed, until it’s all over. So if you’re not careful, you’ll end up with Rust installed in its default location before you can say “God fucking dammit”.

Now, you can (finally) run rustup-init.exe. Make sure to pick option 2) if you want to install the GNU/GCC version rather than the default MSVC, or if you want nightly rather than the default stable. I’m not a fan of using nightly, because it contains features that could get removed at any time, but sadly big frameworks like Rocket require it.

Posted in programming, Windows.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA