Read the latest web development and design tips at Fred Wu's new blog! :-)
Poke me on GitHub

Posts Tagged ‘Gem’

Using Ruby MySQL Gem with MAMP 1.8.x on Snow Leopard

Being primarily a PHP developer, I always use an AMP package no matter what development platform I am on. So when it comes to developing Ruby/Rails applications on the same platform, I’d like to use what is already available.

Mike Boone has posted a very useful tutorial on how to get MySQL gem and MAMP 1.7.2 up and running. So, to recap and make the tutorial compatible with Snow Leopard and MAMP 1.8.x, here is what you need to do:

  1. Download the latest MAMP dmg file.
  2. Download the 1.8.2 (or whichever the latest one you could find) components file from this page.
  3. Unzip, mount the dmg, then copy the MySQL source file (mysql-5.1.37.tar.gz) to somewhere on your hard drive.
  4. Untar the MySQL source file, and `cd` to the source file directory.
  5. Compile the library:


    $ ./configure --with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock --without-server --prefix=/Applications/MAMP/Library

    $ make -j2

  6. Copy the compiled libraries into MAMP:

    $ cp libmysql/.libs/*.dylib /Applications/MAMP/Library/lib/mysql

  7. Copy the MYSQL headers into MAMP:


    $ mkdir /Applications/MAMP/Library/include

    $ cp -R include /Applications/MAMP/Library/include/mysql

  8. Install the Ruby MySQL Gem, on Snow Leopard:


    $ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

    On Leopard:


    $ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

Enjoy!

EDIT @ 2009-11-23: If you’re still experiencing problems (perhaps with RVM), try adding “/Applications/MAMP/Library/bin/” to your $PATH in “~/.bash_profile”.

Related posts