Super Simple Ruby on Rails with MacPorts

Thursday, June 21st, 2007

Macports

I’ve been setting up quite a few Ruby on Rails development environments on various mac’s just recently and I’ve found a pretty nice work flow, so why not share it with the world?

So first up, this is MAC ONLY, sorry windows chaps you’ll have to look else where. I have a list of some other good windows tutorials here.

Update: If you are using OS X 10.5 Leopard you’ll want to use this guide instead: Teabass.com/super-simple-ruby-on-rails-install-with-macports-for-leopard

So lets assume that you have a brand new mac or a clean install and dive straight in:

  1. Install X11 - You’ll find this on the software disc that came with your mac or download from Apple
  2. Install Xcode - Again on the software disc with your mac or you can download the latest version from ADC
  3. Install Macports - Download Macports and run the installer (1.4.0 at the time of writing and you’ll want 10.4 if your using OS X Tiger)
  4. Add macports to your Terminal - Since macports gets installed in /opt/ you’ll need to add the path to your terminal config so you can use it.

    Open ~/.profile with your favourite texteditor and add this line to the bottom of the file:

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

    and then save the file, close it and restart your terminal.

  5. Check for macports updates - in your terminal type:

    sudo port selfupdate

  6. Install Ruby and friends - This is the big one, installing loads of software using macports, in your terminal put:

    sudo port install ruby rb-rubygems rb-termios subversion +tools

    This command could take quite a while to complete as it’s compiling everything from source, make a cup of tea and have a browse on Greenvoice while you wait!

  7. Install MySQL - This is the one that usually causes the headaches so I’ll go slowly:

    sudo port install mysql5 +server

    sudo ln -s /opt/local/var/run/mysql5/mysqld.sock /tmp/mysql.sock

    launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

    At this point restart your machine.

    For a performance boost you can also run this command:

    sudo mysql_install_db5 --user=mysql

  8. Install Ruby’s MySQL adaptor - One last port install:

    sudo port install rb-mysql

  9. Install Rails and friends - So the hard part should be over now, all that is left is to install a bunch of gems:

    sudo gem install rake rails capistrano mongrel mongrel_cluster deprec --include-dependencies

  10. Some optional gems you might like - Money, ferret and OpenID to improve your apps with:

    sudo gem install money ferret ruby-openid --include-dependencies

And your good to go! If this is your first step into rails then head over to “Getting Ryan on Rails” and find out more.

4 Comments so far »

  1. Ew! Don’t edit /etc/profile, add it to ~/.profile

    Caius Durling on July 17, 2007 8:36 pm

  2. How does all this relate with Leopard? Is it the same process? Would I mess everthing up sice Leopard installs ruby automatically?

    dm on October 29, 2007 8:41 pm

  3. I’ve yet to get leopard installed yet, but I would guess that you will still need to install Mysql at a minimum, plus subversion and an image processor like ImageMagic or MiniMagic if you are doing professional rails development.

    I also heard that macports does not work with leopard but I’ve yet to test that either.

    I’m getting leopard at the weekend and I’ll write up a tutorial as soon as I’ve done some testing.

    Hope this helps.

    Andrew on October 30, 2007 10:19 am

  4. […] taken my previous guide for setting up OS X 10.4 Tiger and tweaked it for Leopard plus added some optional extras on the […]

    Teabass - Andrew Nesbitt's Blog » Super Simple Ruby on Rails Install with MacPorts (for Leopard) on November 4, 2007 1:51 pm


Leave a Comment