Software Development | Ruby on Rails
I Got a Mac

Ruby on Rails on Windows is possible but not particularly fun. Most of the supporting documentation is for OS X and/or Linux and things that work on OS X / Linux don't necessarily work on Windows.

Like others before me I gave up and got a Mac - a MacBook Pro with Snow Leopard (OS 10.6) to be precise. So I thought I'd write up some of the things I did to get set Ruby on Rails set up.

Ah, you say, but Ruby and Ruby on Rails come pre-installed on Snow Leopard so no set up required. Well, that is true but I still found some things to do. Read on.

Transfer Existing Rails Applications

First things first. I copied all my existing Rails applications from my Windows machine to my Mac. I put them in a folder called RailsApps within my Home folder.

Separate installation of Ruby and Rails with RVM

Hivelogic: Compiling Ruby, RubyGems, and Rails on Snow Leopard recommends installing Ruby and Rails separately from the Apple provided system Ruby on Rails. He installs Ruby on Rails in /usr/local. Here are the stated reasons from Hivelogic:

  • You want to run the latest/greatest versions of available software and don’t want to wait (or hope) for Apple to release an update.
  • Your want to update, tweak, and customize your own tools while keeping your system “stock” from Apple’s standpoint.
  • Apple may decide to modify these utilities during a system update, and doing so may break your stuff.
  • You can move or remove the /usr/local filesystem, or even transfer it to another machine in one step.
  • You’re used to, interested in, or curious about in the compile and build process.

All fair enough but you get all this and more, and from my perspective easier, by using RVM. With RVM you can have multiple versions of Ruby and keep the original system installed version.  Rails 3 comes with a similar method for managing versions of Gem, and associated dependencies.  I've got a separate article on using RVM and Bundler to manage versions of Ruby, Rails and Gems.

Change the Terminal Prompt

The default terminal prompt is quite verbose and includes information I don't need, e.g. my user name. OS X Daily: How to customise your terminal prompt does exactly that - explains how to tweak the prompt. I went for this command within .profile:

export PS1="\w$ "

This shows the full path, from your home folder, before the "$" prompt.

.profile versus .bashrc versus .bash_profile

My Unix is very out of date. Its been 20 years since I did any seriously. So I'm having to relearn it - in the form of OS X of course. One of the things that has been confusing me is where to put start up commands. For bash - which comes as the default shell in OS X - guides on the internet often mention .bashrc and .bash_profile. However I've had more luck with .profile.  .profile runs when a terminal session is launched where as the other two are only run for a non-login session - I think. 

Seeing Hidden Files in Finder

OS X tries to hide all that messy Unix stuff from the average user. One consequence of this is that you can't see the hidden files (anything beginning with a dot) in finder. This is not something you want to do everyday but as my Unix was rusty I did it to find a particular file.

MacWorld: Show all files in Finder explains how. Open Terminal and enter this command:

defaults write com.apple.Finder AppleShowAllFiles YES

Then relaunch finder to make the change take effect: hold down the Option key, then click and hold on the Finder icon in the Dock; select Relaunch from the contextual menu. Finder will restart.

To hide all that nastiness again requires a very similar Terminal command:

defaults write com.apple.Finder AppleShowAllFiles NO

Get TextMate

TextMate is the default editor for developers on Mac. It is a commercial product but I thought I should give it a go.

SQLITEMAN: SQLITE3 Administration Tool

Actually this is nothing to do with moving to a Mac but the Mac also coincided with my decision to use SQLITE3 for development and testing. I like to be able to browse my databases with a GUI. I thought I'd be out of luck with SQLITE3 but no ... http://sourceforge.net/projects/sqliteman/

Gitx

Gitx is a is a git GUI made for Mac OS X.