Fixing MySQL Gem on Snow Leopard

Posted by on Sep 6, 2009 in Software Tools | 2 comments

NOTE: See my latest post for a solution for OS X 10.6.4 and later

A fresh Snow Leopard (OS X 10.6) install does not have the mysql gem installed, and installing it fails because of missing header files:

Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.


/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

To correctly install the mysql gem:

  1. Download and install the MySQL package.
  2. Install XCode that’s bundled with Snow Leopard
  3. Install the gem for your architecture (use -arch i386 if you have an Intel Core Solo or Intel Core Duo processor):

# sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql-5.1.38-osx10.5-x86_64/bin/mysql_config

2 Comments

  1. Thanks for posting this– very helpful!

  2. Thanks but unfortunately as all the other recommendations it has not resolved the problem. I am installing mysql-5.1.49-osx10.6-x86_64.dmg.

Trackbacks/Pingbacks

  1. MySQL Gem on Snow Leopard - [...] Leopard does not have the mysql gem installed, and my last solution for installing it only work in OS …

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>