Building Ruby 1.9.1 on Windows

As noted else where, ruby 1.9.1 hasn’t exactly bounded out of the gate. That’s not particularly surprising, considering 1.9.1 has been available for only a couple of months and requires changes to existing code. In addition, there are a number of incompatible gems, giving rise to the isitrub19y website as a clearing house of information. So despite the great efforts from the Rails team, the rest of the community is still lagging behind.

That’s particularly true on Windows, where a new one-click installer isn’t yet available. According to the latest market share stats from Net Applications, Windows controls 88% of the desktop market. I have no idea how many Ruby installations exist, and how they are divided by operating system. But looking at RubyForge, by far and away the most popular download of all times is the Windows one-click installer with over 3 million downloads.

Luis Lavena has taken over stewardship of the one-click installer, and clearly needs a bit of help. So although I have very little free time, I offered to pitch in as I could. While Luis is concentrating on putting together a new version of the one-click installer using Mingw and msys, I thought I could help out by putting 1.9.1 through its paces on Windows.

My basic approach was to simply start with the basics:

  • Build ruby with Visual Studio 2008
  • Build the default extensions and libraries Ruby uses (zlib, iconv, openssl, etc)
  • Run Ruby’s unit tests

That was almost a month ago. Thirty-nine patches later (I have no doubt Nobu is getting sick of me), I just about have Ruby 1.9.1’s test suite running on Windows. There a still a few remaining issues, in particular a couple of imap tests that hang.

As for Visual Studio, I’m using it for two reasons. First, it has a lights-out debugger that makes it much easier to track down and fix problems. Second, its lets you compile instrumented executable and libraries that can detect incorrect API usage, heap corruption, stack corruption and mismatched calling conventions.

It quickly became obvious that no one had ever done that with Ruby, because it turned up a whole host of issues. For example, the dl extension used the cdecl calling convention to call the Windows API instead of stdcall. Or that there were a set of memory leaks in printf/sprintf.

The other thing that was bothersome was the huge number of compiler warnings generated by building Ruby. See for your self – and then realize the original list doesn’t include any of the warnings generated by building Ruby’s extensions. Cleaning up the warnings took a number of patches, but at this point most of them have been fixed. And all credit to Nobu for working through my patches, fixing them and applying them since my knowledge of the Ruby runtime is fairly limited, thereby causing most of my patches to not be quite right.

Anyway, since its not all that obvious how to build Ruby on Windows (with Visual Studio or Mingw), I’ll see if I can put together a few posts that describe how to do it for anyone who wants to roll their own.

  1. March 29, 2009

    Excellent news. And not before time that someone tried building Ruby using the MS compiler: it’s probably safe to assume that they know something about compiling for Windows.

    How close are you to benchmarking?

    Reply
  2. March 29, 2009

    I think many Ruby programmers would be interested to have ability to build ruby intself on windows. It was always black magic for me and there’s almost no info on the web how to do that. I’m interested to read about it on your blog :).

    Reply
  3. March 29, 2009

    The recently heightened buzz about the importance of the switch to 1.9 makes it even more surprising to learn that there is a relative shortage of help for putting out an updated installer. Perhaps an open call in the Ruby community could have helped to get additional assistance? Kudos to you for taking this on and sticking it through.

    Reply
  4. Rayon Hunte
    April 3, 2009

    my boss wants to use ruby, but the lack of a windows installer for 1.9 might move us to php. i hate php is there any way i can get the install instructions in advanced.
    so i can use the binary files

    Reply
  5. April 6, 2009

    I would love to read your instructions for building Ruby 1.9.1 on Windows. Furthermore, I’m surprised there isn’t a binary installer yet.

    Thanks!

    Reply

Leave a Reply

Your email address will not be published.

Top