Last month I started rewriting the admin reporting section of one of my sites in Merb rather than refactor the existing PHP version, for a number of reasons. The pace of development with Ruby and Merb was tremendous and within about a week and a half I had a fully-functional, extensible reporting site developed, replete with graphs and statistics. DataMapper made tying into the legacy database, with it’s rather novel table and column naming schemes, trivial. It was all tremendously satisfying and, dare I say it for a project so unglamorous, fun.
And then I tried to get it to run on our production server, which is running Red Hat Enterprise Linux 5, and the fun went away.
I first tried installing Phusion Passenger (a product I’m absolutely enthralled by) but no such luck; it had a hell of a time with the default Apache install and lack of development headers and various file locations. I wasn’t willing to muck about with the production server in a vain attempt to force it to work at the risk of the rest of the site.
Instead I figured it ought to run just fine on Rack. And every dependent gem installed with nary a hitch save for DataMapper, specifically do_mysql, which would fail to build the native extension with the following error:
In file included from /usr/include/mysql/my_global.h:83, from do_mysql_ext.c:6:
/usr/include/mysql/my_config.h:15:28: error: my_config_i386.h: No such file or directory
The solution was ultimately provided by Dan Kubb:
We probably should make it so that all the DO driver specs can be run on installed gems, but in the meantime, checkout the source from git using the following commands:
git clone git://github.com/datamapper/do.git
cd do/data_objects
sudo rake install
cd ../do_mysql
... remove the references to my_config.h in do_mysql ...
rake compile spec
sudo rake install
This will first install the edge version of DataObjects, and then will compile and run the specs for do_mysql, and then install it. You will want to remove all references to my_config.h from the do_mysql C libs just prior to running the specs of course.
The really important bit here: “remove the references to my_config.h in do_mysql”. That’s the magic, and with that everything was good and right and Merb was run, and the users were happy.
(For the very curious, the entire DataMapper Google Groups thread.)
chris on February 20th 2009 in /dev/random, /dev/ruby