The Tricky Business Of Setting up a Rails Development Environment on OSX

Posted by bitbutter on June 26, 2007

I have a brand new mac running OSX 10.4.7 so i thought that it should be relatively straightforward to get a rails environment set up if i found the right guide. It took me a day to get this working. Here I’m documenting what i think i should have done to have it work first time, for my reference for next time. Perhaps its useful for other people too.

First i looked at the The hivelogic guide but ultimately the approach i took was a combination of the Snax guide and James Duncan Davidson’s guide which both sounded like improvements on the hivelogic approach.

I had some troubles with both guides, probably due to my cluelessness in command line land. So i compiled a list of steps I should have taken. I hope this guide will save some hours the next time (Update: yes it did). NB This whole procedure will take some hours to complete.

Get it right first time

Install Xcode

Following the tutorial here.

Download the latest version of macports

from here. Then install macports following the instructions in the download.

Edit the PATH variable

This is to make sure your system looks in the macports directory for your stuff.

PATH=”/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin”

Copy this PATH assignment line and paste it over any existing path assignments in /etc/profile.

(etc is a hidden folder. If you'd like to use finder to navigate to it you'll need to configure it to show hidden files)

Make sure stuff is up-to-date

$ sudo port selfupdate

Install a bunch of other stuff

$ sudo port install apache2
$ sudo port install mysql5 +server
$ sudo port install subversion +tools
$ sudo port install ruby
$ sudo port install rb-rubygems
$ sudo port install rb-termios
$ sudo port install rb-mysql
$ sudo port install rb-rmagick

The last command may give an error complaining that "You have an Apple X11SDK installation already.", but you can safely ignore it. It's also good to know that the task "Building XFree86 with target World" will take a long time to complete. This is normal.

Install some ruby gems

$ sudo gem install -y rake
$ sudo gem install -y rails
$ sudo gem install -y capistrano
$ sudo gem install -y mongrel
$ sudo gem install -y mongrel_cluster

Set mysql to autostart next time machine is turned on

$ sudo mysql_install_db5 --user=mysql
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

Get a gui for MySQL

Download Cocoamysql and install it by following the instructions in the download.

You'll need to restart your computer before you can start working with databases (to get mysql going). Once youve done that you connect to your mysql server by accessing File > New in CocoaMySQL. To set up a connection to your local mysql server in CocoaMysql use the following details: host:127.0.0.1 [‘localhost’ didn't work for me], username: root, password: [no password].

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

Comments