Foliosus Web Design LLC: Your website done right

Blogfolio

HOWTO: Install mysql gem on Leopard

Sep 12 ’08

A while ago, when I upgraded to Rails 2.0, I started getting the annoying "upgrade to the real mysql library" message every time I did anything with rails from the command line. Running rake tasks, running tests, opening a console session, I'd always get the error. When I would try to install the gem (sudo gem install mysql) I'd get the following error:

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

blah blah blah

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Configuration fail!

It seems that this is particular to Leopard. I just discovered the solution in an old post from the RoR blog:

sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/usr/local/mysql

We're not quite there — if you try to config.gem 'mysql' in your environment.rb you'll get an error. The solution (thanks to macruby.org is to:

sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql

And that's it. Two steps and we're fixed. No more annoying messages.

Command line win!

Conversation in progress…

  1. 1

    On September 18th James said:

    Hi, I found your blog on this new directory of WordPress Blogs at blackhatbootcamp.com/listofwordpressblogs. I dont know how your blog came up, must have been a typo, i duno. Anyways, I just clicked it and here I am. Your blog looks good. Have a nice day. James.

  2. 2

    On October 17th jonathan said:

    dude, you're the man. after looking at 20+ blogs/forums yours is the only one that works, many thanks

  3. 3

    On December 3rd Igor Petrushenko said:

    Hi, all

    The only one thing, which actually works for me:

    sudo gem install mysql -- --with-mysql-config=`which mysql_config5`

    Thank you,
    Sincerely,
    Igor,
    http://www.MyTaskHelper.com

  4. 4

    On December 20th Brent Miller said:

    I just got a new 24" iMac, running the latest Leopard; I ran into this problem again while building the new system. This time, with the latest MySQL package (5.1.30), the following command worked:

    sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=`which mysql_config`

    This uses Igor's suggestion, but works better for the current MySQL package.

  5. 5

    On June 14th Travis said:

    Sweet! Totally fixed the errors I was getting trying to install the mysql gem. Thanks!

Join the conversation

* indicates a required field

New comment

Will never be disclosed or used inappropriately

Enter the word how to confirm that you are a human being

About the author

Brent Miller is the owner and principal web designer of Foliosus Web Design LLC in Portland, Oregon. He enjoys food, plants, and the color green. If you are interested in hiring him for web work, please contact him.

Categories

Plant of the day

Unknown sp. (Bromeliaceae)

Unknown sp. (Bromeliaceae)

Fresh photos