Building Ruby 1.9.1 on Windows

Posted by Charlie Sun, 29 Mar 2009 04:29:00 GMT

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.

Posted in  | 9 comments | no trackbacks

Comments

  1. Avatar Mike Woodhouse said about 9 hours later:

    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?

  2. Avatar Radarek said about 11 hours later:

    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 :).

  3. Avatar kq said about 15 hours later:

    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.

  4. Avatar Rayon Hunte said 5 days later:

    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

  5. Avatar JP said 8 days later:

    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!

  6. Avatar MrBuddha said about 1 month later:

    I’m very interested in these instructions as well. My own attempts so far to build Ruby with mingw, esepcially with all the required dependencies, always ended up in a desaster… Any news on that topic? Thanks!

  7. Avatar Jonty said about 1 month later:

    Thanks for doing this Charlie - I too am a ruby-windows user very frustrated at the lack of a windows build of 1.9

    have you got anywhere with some instructions?

  8. Avatar roger said about 1 month later:

    I put together some mingw instructions here: http://betterlogic.com/roger/?p=1354 Not exactly a one click install process but hey, we do what we can :)

    Also could I request a version bump of the ruby-prof gem (do you control that?) – the current gem doesn’t compile on 1.9, but I believe the svn trunk does Thanks! ref: http://rubyforge.org/tracker/index.php?func=detail&aid=24378&group_id=1814&atid=7060

  9. Avatar Edgardo Rossetto said about 1 month later:

    Any luck building the iconv extension with vs c++? I can’t get past that one yet

Trackbacks

Use the following link to trackback from your own site:
http://cfis.savagexi.com/trackbacks?article_id=508

Comments are disabled