Posted on Aug 10, 2008

RubyGems: With power comes responsibility

Sounds like a movie, but should be applicable on every day work. I found that even you can trick RubyGems to do something, it doesn’t meant it is right. Please keep reading to understand my opinion.

The power behind –platform

Since version 1.0 of RubyGems, there is a new parameter that let you force the platform on which you’re installing the gem.

Note that I highlighted force… you may wonder why?

Since I started to work on MinGW built of Ruby, lot of gems require a bit of tweaks and rework since they are not prepared to handle mingw32 like they do for mswin32 platforms. Some of them just the binary part, some other logic into the Ruby code.

Since there are lot of gems that are not ready for mingw32, someone can force the use of mswin32 since MinGW and Visual C compiler states to be binary compatible, but that doesn’t meant the library is.

This was raised by Fabio Akita in rubyinstaller-devel mailing list (check it here) and I replied there too.

Even you can install the gem on different platforms it doesn’t meant will work.

Mongrel 1.1.5 is a great example of that. I put my time in fix 1.2 branch for MinGW instead of 1.1.x series since I thought was the next release in the roadmap, and I got it wrong.

So 1.1.5 go out without a proper MinGW condition of the platform and even if you forced the platform during the gem installation, Mongrel wouldn’t work.

I fixed this and released a proper mingw32 gem of Mongrel 1.1.5 for you guys to download one week ago. Please remove the incorrect one (gem uninstall mongrel) and install the proper one.

Other libraries may face the same issue, so be careful with the powers you have, use them wisely.


  • Luiz says:

    Thanks now my problems are solved tnx for the fix!

  • akitaonrails says:

    Thanks luís, I Will write another post explaining this. Now the problem is that it is not obvious how one should proceed to have all the gems that are currently only available for mswin32.

  • Luis says:

    Yeah Fabio, the thing is that not all the gems have this problems with mswin32 / mingw32.

    I’ll try to write a post as tutorial for people to contribute and spot those issues, but dunno if that will help.

  • […] RubyGems: With power comes responsibility […]

  • roger says:

    Yeah really what you should do for gems that don’t compile is not force but figure out why and alert the author. IMO the ideal is just for gems to all compile out of the box for mingw, but that’s just me ๐Ÿ™‚
    [mongrel does…others can too]

  • […] public links >> rubygems DEV_MEM.dump_to(:blog) :: RubyGems: With power comes responsibility Saved by jagayx on Sun 26-10-2008 rubygems: updating to 1.2.0 Saved by buroku on Thu 23-10-2008 […]

  • Guido says:

    Thanks for linking me here from that other post. I seem to have a problem with the mingw32 version of the mongrel gem as well though:

    D:\Rails\testproject>ruby script/server
    F:/Ruby/lib/ruby/gems/1.9.1/gems/mongrel-1.1.5-x86-mingw32/lib/ [BUG] Segmentation fault
    ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32]

    — control frame ———-
    c:0019 p:-14382694 s:0073 b:0073 l:000072 d:000072 TOP
    c:0018 p:—- s:0071 b:0071 l:000070 d:000070 CFUNC :require
    c:0017 p:0012 s:0067 b:0067 l:000056 d:000066 BLOCK F:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156

    Any idea what I’m doing wrong? (And huge thanks for your help!)
    (Concerning MySQL, 5.0 didn’t work for me either ๐Ÿ™ – I installed the 5.0 essentials, ran the service, even made the database, and rake db:migrate would produce exactly the same segfault error as it did with 5.1)

  • Guido says:

    I think I’ll go and see if I find a mysql-specific mailing list, and ask there ๐Ÿ™‚ There’s bound to have been somebody else with the same problem.

  • Luis says:

    @Guido: it seems you didn’t read my comments. so I’m going to explain once again.

    You installed the binary of mongrel for mingw32 platform, but for the wrong version of ruby.

    The binary of Mongrel was built for 1.8 version of Ruby, not for 1.9!

    You need to remove the binary gem and install the one labeled as “ruby”, so:

    gem install mongrel --platform=ruby should do the trick.

    Anyhow, as I mentioned here, 1.1.5 gem got released but I’m not 100% sure it got all the MinGW fixes in.

    regarding MySQL, you’re facing the exact same problem I mentioned before: running compiled extension for 1.8 against 1.9, that is not going to work.

    I believe that is happening because you have both 1.9 and 1.8 on your PATH environment.

    I know is hard to follow and understand all those little details, but this is exactly the same under any kind of operating system.

  • Guido says:

    I did read all your comments, I guess it’s one of those common things where something that’s very basic to you and everybody else who is used to compiling stuff on Windows but alien to me is not made explicit. Is there a way I can easily tell whether a gem is precompiled or not?

    I only have Ruby 1.9 in the path – I put 1.8 in there only for a few minutes, for testing whether mysql works with 1.8. It did, so you’re certainly right about me getting an 1.8 precompiled version. I’ll look into this again. Currently extconf.rb fails, not finding mysql_query() in -lmysqlclient, eventhough I do have libmySQL.dll available through the path. I don’t seem to be the only one with that problem though, I’m sure I’ll find a solution soon.

    gem install mongrel --platform=ruby

    doesn’t seem to work either, it gives me the error “http11.c:77: error: structure has no member named `ptr’”:

    It seems that the version of the gem I got doesn’t have these fixes here: – and if I attempt to change the C file by hand and then gem install again, the file reverts to its previous version, probably because of the package system?

  • Luis says:


    I know must be itching right now, but if you give me a couple of days to put a step by step guide everybody would benefit.

    Basically the mysql gem available would not work, it broken for 1.9, so you need to use my project at GitHub.

    On the Mongrel side, there are lot of things that need improvement over there.

  • Guido says:

    A step-by-step guide like that would be awesome, and well worth a wait indeed ๐Ÿ™‚ Thanks a lot for all your answers!