devroom.io/drafts/2006-12-06-install-ruby-mysql-on-mac-os-x-104-tiger.md
Ariejan de Vroom dbae98c4c0 Moar updates
2013-03-24 14:27:51 +01:00

1.3 KiB

title kind slug created_at tags
Install ruby-mysql on Mac OS X 10.4 Tiger article install-ruby-mysql-on-mac-os-x-104-tiger 2006-12-06
General
Everything
RubyOnRails
Features
Mac OS X

You probably know that the built-in mysql code in Rails sucks. To rephrase that, the ruby-mysql gem contains better code, so you want that. Rails automatically detects if you have ruby-mysql installed or not, and uses it if you have it.

Most notably, you want to install this gem if you get dropped MySQL connections running your Rails application.

So we do:

$ sudo gem install mysql
...
ERROR: Failed to build gem native extension.

Normall this would install fine, but not on Mac OS X. This is because Mac OS X keeps its code, headers and libraries in odd places (compared to Linux). But don't panic. There's an easy solution to all this!

Just compile the gem yourself, and add some special ingredients. Well, not even that. Just compile it again like this:

$ cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
$ sudo ruby extconf.rb --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include
$ sudo make
$ sudo make install

Now, you have the ruby-mysql gem installed and ready to go! No more dropped MySQL connections for Rails!