Rails MySQL and Leopard
I didn’t know about the ARCHFLAGS environment variable, this is a less intrusive way (thanks to Sebastian for pointing this out):
sudo su - ARCHFLAGS='-arch i386' gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
(sudo su – asks you for your normal password not the root password)
I’m using the stock ruby environment on Leopard and the MySQL Package from http://www.mysql.com.
Unfortunately installing the mysql driver as a gem doesn’t work out of the box and the default mysql driver that comes with rails seems to be quite buggy.
To get it working we have to remove all occurrences of “-arch ppc” in rbconfig.rb, otherwise it tries to compile the mysql driver for the powerpc plattform as well, what we don’t want (assuming you have an Intel Mac, otherwise remove “-arch i386″).
We also have to tell the driver where to find the the mysql libs, includes and so on. We can do this by specifying where the path the mysql_config command.
cd /usr/lib/ruby/1.8/universal-darwin9.0/ sudo mv rbconfig.rb rbconfig.rb.orig sudo sed "s/-arch ppc//g" rbconfig.rb.orig > rbconfig.rb sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
(if you use a PPC Mac replace ppc with i386 on line 2)