Install Ruby on Rails using MAMP

Posted by admin on June 02, 2009

I just installed ruby on rails, following the official tutorial http://hivelogic.com/articles/view/ruby-rails-mongrel-mysql-osx (MacOSX 10.4),  so everything works except that for me I had to update my .bash_profile and not .bash_login.


mate ~/.bash_profile

Then copy paste (I remove the MySQL path because the plan is to use MySQL of MAMP)


export PATH="/usr/local/bin:/usr/local/sbin:$PATH"

The rest of the tutorial is fine, keep going with the official tutorial until the MySQL part.

If for the MySQL configuration you are encountering this error :


sudo gem install mysql -- --with-mysql-config=/Applications/MAMP/Library
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.

You are in the same situation I was, then I found this solution http://boonedocks.net/mike/archives/175-MAMP-and-the-Ruby-MySQL-Gem.html the beginning worked well until I had to compile …
I resume the steps to make it worked, first download the source code of MAMP (this suppose that you already have MAMP 1.7.2 installed properly), then unzip the source code, untar the MySQL archive and compile the libraries for the Gem :


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

This where I encountered another problem, I had this error :


./configure --with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock --without-server --prefix=/Applications/MAMP/Library
checking build system type... i686-apple-darwin8.11.1
checking host system type... i686-apple-darwin8.11.1
checking target system type... i686-apple-darwin8.11.1
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking "character sets"... default: latin1, collation: latin1_swedish_ci; compiled in: latin1 latin1 utf8
checking whether to compile national Unicode collations... yes
checking whether build environment is sane... yes
checking whether make sets $(MAKE)... (cached) yes
checking for gawk... (cached) awk
checking for gcc... gcc
checking for C compiler default output file name... configure: error: C compiler cannot create executables
See `config.log' for more details.

This one was simple, check which compiler version you are using, If you are using gcc 3.3 (like me) you must switch to the version 4.0, if you don’t have it you can grab it on the mac osx installation cd.


 sudo gcc_select 4.0
Default compiler has been set to:
gcc version 4.0.1 (Apple Computer, Inc. build 5370)

And then just follow the end of the tutorial and anything should work like a charm

ror_install