I’ve been a ruby lover for a while, but I haven’t been able to do any free time programming. Last night I found some time and decided to start a little ruby-gnome2 project on my pc at home which runs Ubuntu Feisty Fawn. I was amazed to see that it was not as easy as I’ve grown accustomed to things being with Feisty. To make a long story short, I had to do some dependency chasing, but after the chase was completed I was able to get a fully functional ruby-gnome2 environment up and running before bed time 🙂 Read on for details!
At first I figured that it would be very simple to get ruby gnome development going, since Ubuntu uses gnome by default and I had ruby installed already. To be honest about 95% of my Ubuntu experiences so far have been pleasant surprises. I had forgotten that using a desktop distribution for development can be frustrating, if only because the development libs that an average desktop user won’t need are all available but not installed by default. This is what I had installed when I started, I’m not sure if I had installed some of these explicitly or if they came by default (note this is just the stuff that pertains to ruby):
Now of course since I am running gnome I have gtk2, pango, atk, gconf2, etc. all installed because gnome depends on those in order to run. Seemed pretty complete, so I moved ahead and installed ruby-gnome2.
I was immediately prompted that ruby-gnome2 will install the following:
Wow! That’s a lot of stuff. But hey it all installs with a couple of clicks and so I installed it all in a matter of mins. Now I figured I was all set so I tried the hello world program from the ruby-gnome2 tutorial (see the ruby-gnome2 homepage at http://ruby-gnome2.sourceforge.net). Does it work? Well…. sort of…
I got a small window with a button but I also got a terminal full of ugly errors! I certainly don’t consider a program working if it spits errors such as the following:
/usr/lib/ruby/1.8/glib2.rb: line 55
GLib-GObject-CRITICAL **:g_boxed_type_register_static: assertion `g_type_from_name (name) == 0′ failed
Now keep in mind that the button does work, it and the application does everything it’s meant to do. The problem is that is does a little too much 😉 I did some research and found out that the cause of all those errors is that the ruby-gnome2 in the feisty repository is old. Upgrading to 0.16 should do the trick. Now the real fun begins…
I found bug reports in ubuntu’s database asking for a ruby-gnome2 update so I didn’t file another. It turns out that ruby-gnome2 has been available since my friend Larry’s birthday last year, December 29, 2006. That’s quite a bit of time, but I’m not going to complain. The source is open and free – I can download it myself and make progress instead of wasting time complaining about it, right? So that’s what I did.
Now be warned… what happens from here on may or may not break your ubuntu packaging a little bit (or a lot?). This is because installing things from source will overwrite the files installed by ubuntu’s package system. Even if I create an updated package and release it here, it would not be an official package and could create problems anyway. I can tell you that what I describe below works for me, but remember that YMMV 🙂 Ok back to the fun!
This is what happened when I tried to install ruby-gnome2 from source:
extconf.rb:9:in `require’: no such file to load — mkmf (LoadError)
Oops! well now… what could that be? After some research I found out that mkmf is part of the ruby development package, namely ruby1.8-dev. Installing that is another few clicks away and so I went ahead and did that. Unfortunately that didn’t quite solve my problem either. What happened is that extconf.rb ran (since mkmf was installed) but the configuration had major problems! So major, in fact, that every piece of the ruby-gnome2 libraries was listed as ignored:
Ignored libraries: glib, gdkpixbuf, pango, atk, gtk, vte, rsvg, gnomeprintui, gconf, gnome, panel-applet, gnomeprint, gnomecanvas, gtkmozembed, gtkglext, gtkhtml2, libart, gnomevfs, gtksourceview, libglade, poppler
Certainly can’t move forward with every piece of the library being ignored, right? So I investigated. This is the part that took the most time, because the log files I needed to check were mentioned up at the top of this long long list of output from extconf.rb. I have experience building packages (I cut my linux teeth on linux from scratch (linuxfromscratch.org) so troubleshooting things like this is not uncommon to me. I dug deep and found that the errors listed in the mkmg.log file were caused by… can you guess? Yes that’s right – more missing development packages. For those interested, the errors are similar to this:
conftest.c: In function ‘t’:
conftest.c:3: error: ‘rb_define_alloc_func’ undeclared (first use in this functi
I searched high and low for conftest.c but found that it’s just a temporary program that is created and deleted during the course of configuration. The problem was not within conftest.c. To get to the heart of the problem I had to enter the glib directory (a subdirectory of ruby-gnome2-all-0.16.0) and run extconf.rb there. It showed me:
checking for gobject-2.0… no
And *that* is the clue that lead me down the right path toward solving this configuration problem. I searched around for gobject-2.0 and found that it’s part of the glib-dev package. Doh! I have glib2, but not glib2 development libraries. In fact I have gtk2, pango, atk and all of these gnome libraries, but not their development libraries. In order to build development extensions for those libraries you need the development components of those libraries. So here’s what I did –
I found libglib2.0-dev and installed that… and re-ran extconf.rb. It worked! Now I realized that I was probably missing other development packages so instead of doing things one at a time, I just searched for the library names that were ignored (see above) and I found the development packages associated with each, and installed them. A list follows:
These and all of their dependencies came to a total of 92 more packages that needed to be installed. Luckily it’s all very simple and fast if you have a good internet connection 😉
Once those were installed I ran the extconf.rb script from the top level of the ruby-gnome2 source and found that gtkmozembed, gtkglext, and poppler were still being ignored. I had to attack these one at a time.
I looked and found that mozilla-gtkmozembed was not found. This is supplied by libxul-dev which needs xulrunner and…
Depends: libnss3-dev but it is not going to be installed
Depends: libnspr4-dev but it is not going to be installed
Depends: libmozjs-dev but it is not going to be installed
What to do now? Go crazy?No, don’t go crazy! Just install firefox-dev.
Next up is gtkglext… that will need libgtkglext1-dev.
Finally, the popper extension – that needs libpoppler-glib-dev installed.
Now that I had all of that stuff installed, I removed the ruby-gnome2 tree and unpacked it so I would be working from a fresh tree. I ran extconf.rb and found:
Target libraries: glib, gdkpixbuf, pango, atk, gtk, vte, rsvg, gnomeprintui, gconf, gnome, panel-applet, gnomeprint, gnomecanvas, gtkmozembed, gtkglext, gtkhtml2, libart, gnomevfs, gtksourceview, libglade, poppler
That’s all of them! Finally After all that work, running helloworld.rb gives me a box a button and no errors! Now the real fun can begin 🙂