A long, hard and uneasy process for pretty much everyone on a new mac (as of today).
After about 10-15 different methods, a couple of complete re-installations of Mac OS, I have finally been able to pinpoint exactly what it takes to get Rails fully up and running on the Mac.
I will first break down all the issues that have caused me problems;
The version of ruby that comes preinstalled on OS X 10.8 is outdated relative to the version of Rails that has to be installed. Hence installing Rails by itself is not ordinarily possible.
In order to install rails (as will be shown below), an newer version of ruby must be installed. This causes problems when installing the gems (such as mysql2) as the location of the new ruby installation is not in the same location as the native ruby on OS X.
How to successfully install rails.
Install Xcode from the Mac App Store (v4.6.3)
a) Install command line tools: Xcode > Preferences > Downloads > Command Line Tools (Install)
Download and install Railsinstaller from http://railsinstaller.org
a) There will be an error the first time you try. This is normal, just restart your mac and try again.
Download and Install MacPorts (https://distfiles.macports.org/MacPorts/MacPorts-2.1.3-10.8-MountainLion.pkg)
Install MySQL (http://dev.mysql.com/downloads/)
We can now install MySQL via MacPorts;
Open Terminal and type;
sudo port install mysql55 mysql55-server
- We can now install mysql2 gem; In Terminal type;
sudo gem install mysql2 -- --with-mysql-config=/opt/local/lib/mysql55/bin/mysql_config
Now when you are accessing a ruby project through localhost, you are bound to get a mysql2 error when you hit 'About your application’s environment'.
A work around for this is with rake;
1. First install rake with (terminal);
sudo install rake
- Then move terminal to the directory of your ruby project (e.g. cd Sites/ruby_project) and enter in terminal;
This will solve the problem