Installing ruby-mysql on OS X Leopard
October 23rd, 2008By: Steven Haddox
So I was receiving a lovely deprecation warning from Rails tonight that if I didn’t install the C-library mysql adapter for Ruby then my applications would stop working in my environment when Rails 2.2 is released. I decided it couldn’t be too hard to install the adapter and found out that there are a few problems with using the default gem install mysql when you are running the OS X Leopard mysql.com installation.
Anyway, the short and sweet of this is that there is a solution if your mysql gem install is giving you grief in Leopard. Simply run the following command and take note of the options in the parameter –cflags after the -I/usr/local/mysql/include directory. Those options will need to be passed in as your ARCHFLAGS value when you execute your gem install:
$ mysql_config
Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
Options:
--cflags [-I/usr/local/mysql/include -Os -arch x86_64 -fno-common]
--include [-I/usr/local/mysql/include]
--libs [-L/usr/local/mysql/lib -lmysqlclient -lz -lm]
--libs_r [-L/usr/local/mysql/lib -lmysqlclient_r -lz -lm]
--socket [/tmp/mysql.sock]
--port [3306]
--version [5.0.51b]
--libmysqld-libs [-L/usr/local/mysql/lib -lmysqld -lz -lm]
In my instance (on a Mac Pro and MacBook Pro) I was able to get ruby-mysql working with the following command:
$ sudo env ARCHFLAGS="-Os -arch x86_64 -fno-common" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config









![[del.icio.us]](http://stevenhaddox.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://stevenhaddox.com/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://stevenhaddox.com/wp-content/plugins/bookmarkify/facebook.png)
![[Google]](http://stevenhaddox.com/wp-content/plugins/bookmarkify/google.png)
![[MySpace]](http://stevenhaddox.com/wp-content/plugins/bookmarkify/myspace.png)
![[Newsvine]](http://stevenhaddox.com/wp-content/plugins/bookmarkify/newsvine.png)
![[Slashdot]](http://stevenhaddox.com/wp-content/plugins/bookmarkify/slashdot.png)
![[StumbleUpon]](http://stevenhaddox.com/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Email]](http://stevenhaddox.com/wp-content/plugins/bookmarkify/email.png)
will try this out when my mac mini arrives next week !
Comment by Tinu — October 24, 2008 @ 12:56 am