Leopard and MySQL Gem

Those of you doing rails development work on Leopard with MySQL have probably seen this error message when starting your app:

WARNING: You’re using the Ruby-based MySQL library that ships with Rails. This library is not suited for production. Please install the C-based MySQL library instead (gem install mysql).

Normally I don’t care, but I figured since I was doing some cleanup today and getting things ready to move on to a longer term it might be good to have a properly working MySQL gem.  I like to run with a system that is close to what we run production.  The closer you get, the less surprises you have when you push it live.

More Fixing.  Less Talking.

Damn you’re so pushy sometimes.  Anyhow.  I did a sudo gem install mysql and got another damn error.

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
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
*** 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.

Oh good.  Another error.  Perfect.  I searched around the interwebs and someone suggested using “–with-mysql-lib=/usr/local/mysql/lib” in the options since that’s where the libraries are located.  It still barfed on me with that.

A Solution Please.

A few more minutes of hunting and pecking and I found the golden command:

sudo gem install mysql -- --with-mysql-config
Building native extensions.  This could take a while...
Successfully installed mysql-2.7
1 gem installed

Now I don’t have any errors when starting my rails applications that use MySQL and I’m closer to what I have in production.

Posted in Code, Software Development, Uncategorized, ruby at November 6th, 2008. Trackback URI: trackback
Tags: , , , , , , ,

2 Responses to “Leopard and MySQL Gem”

  1. December 3rd, 2008 at 2:01 am #Patrick Tulskie

    I actually just had to use this again when I setup my new Macbook the other day. I sure am glad I wrote it here :)

  2. March 9th, 2009 at 2:22 pm #Nick Rudzwick

    Dude, that is a keeper!

    It took a little bit more to get mine working, with Patrick’s help!

    1. make a bash_login file
    2. stick this in it:

    export PATH=”$PATH:/usr/local/mysql/bin”

    3. save it
    4. open a new terminal window
    5. Lastly, type this in terminal:

    ARCHFLAGS=”-arch i386″ sudo gem install mysql — –with-mysql-config

Leave a Reply

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