Andrew Fontaine

Mostly code

Development on Windows - Ruby

16 Jul 2015

Continuing on with our “Developing on Windows” series, we will now be talking about Ruby. Why does everyone think that you can’t develop on Windows? Our last post talks about getting a decent set up for vim.

Compared to that, this is actually not too bad. It follows three steps:

  1. Run the Ruby Installer
  2. Install the Ruby DevKit
  3. Make sure everything is in your $PATH

Ruby Installer

Pretty straightforward, really. Run it. Let it install. Make sure to check all the boxes you see, including adding it to your $PATH. Restart any shell sessions, and make sure irb launches the Ruby REPL. Good? Good.

NOTE: I’d also recommend installing pry, as it’s an overall nicer interactive Ruby shell.

Ruby DevKit

Look… the DevKit is necessary. It’s just a small MinGW bundle that can hook into RubyGems, and then you can build most C extensions as much as you want. Some of them might not work, especially if they rely on Kernel#fork, but that’s OK. It’s okay! You will be OKAY! You’re not deploying web apps on a Windows Server environment, you’re just making changes and doing work and stuff. Easy as that.

RubyGems

You should now be able to gem install to your heart’s content. Unless, that is, you run into a stupid SSL error. If you’re having that issue, it usually means your version of RubyGems is out of date. Unfortunately, you can’t update it, because it self-updates! Fortunately, RubyGems is still accessible without SSL, so if we temporarily change the source, we should be able to update just fine.

$ gem sources -r https://rubygems.org/
$ gem sources -a http://rubygems.org/
$ gem update --system
$ gem sources -r http://rubygems.org/
$ gem sources -a https://rubygems.org/

If that doesn’t work, we have a much stranger problem. Take a look at the this gist to try and salvage things.

This is a rather old issue, and should be fixed everywhere, but I’ll leave it here for reasons.

Adding Stuff to Your $PATH

The easiest way to do this is actually through the Control Panel, under User Accounts (it’s on the left side called “Change my environment variables”), because the Powershell commands are unnecessarily long and complex. It’s under the User Settings in the Control Panel. Also make sure to add .RB; to your PATHEXT variable, so you can run ruby files like ./test.rb, and so ConEmu will run ruby commands in their emulator instead of spawning a new and separate window that you then have to pay attention to.

Look. It’s not perfect. It’ll never truly be perfect, but Linux and Mac aren’t perfect either. There’s just more resources and tools, because that’s what people use. You can use Windows though! Rails works, Sinatra works, base Ruby works. It all works… mostly.

I ❤ feedback. Let me know what you think of this article on Twitter @afontaine_ca