OS X MySQL Ruby Gem Install Problem

While I was busy humping ActionScript, Ruby installation on my Mac laptop broke. During reinstall, I noticed that MySQL gem failed to update. After collecting tips and misleads off the net, none of which worked as is, I found a combo that worked for me:

  1. Edit mysql.h to defined 'ulong' as unsigned long
  2. Use dash-dash space dash-dash for parameter
Apparently, mysql.c in MySQL gem uses ulong which is not defined anywhere so gem install fails. If you define ulong inside mysql.c then make/install, the gem won't show up in the gem list and gem install command will wipe out any change you make, so hacking mysql.h from local MySQL installation seems to be the path of least resistance.
 MySQL is installed at /usr/local/mysql on my laptop so, for step 1, I edited:

/usr/local/mysql/include/mysql.h

then ran (watch the Morse-codish crap):

sudo gem install mysql — –with-mysql-dir=/usr/local/mysql

Total time wasted: 2 foul-mouth hours. Some folks reported success by switching to GCC 3.3 (sudo gcc_select 3.3) but not for me. Above fix works with GCC 4.0 (sudo gcc_select 4.0).

Advertisements