Preparing Mac OS X Leopard for Camping

Preparing Mac OS X Leopard for Camping

These notes are for setting up a fresh OS X Leopard system (10.5.8) to run Camping, in as few steps as possible. It presumes you know how to use Apple’s Terminal, but may not have arrived here via Rails. If you want more, there’s an extensive article on setting up OS X for Ruby development elsewhere, and you can also read the Ruby gems install guide. If you aren’t using OS X see this article to set up Ruby on Windows or Linux. If you know better, please edit this page!

If you don’t have it already, install the latest Developer Tools that will run on 10.5.8 (XCode 3.1.4). You can get XCode 3.1.4 from Softpedia or from Apple’s Developer Connection (free to join). You can then try the Camping tutorial in the free XCode environment and editor.

Gem locations in Leopard

Gem locations in Leopard

Camping and the gems it uses can easily be installed with the default Leopard system. There are various sources of information (and warnings) about this but (if you aren’t using Macports, Homebrew or installing to usr/local) never fear, here’s what you need to know.

The default gems that come with Leopard are at:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

Your updated and new gems are installed by default at:
/Library/Ruby/Gems/1.8

Finally, if you’ve ever done gem install as a non-admin user (i.e. not using sudo) you might have a .gem folder in your Home folder, which you can safely remove (unless you’ve deliberately added it to your path and want to keep your own gems separate from the system), then re-install the missing gems using sudo.

You can update RubyGems with sudo gem update --system and although some warn of fixes required for applications like Aptana and NetBeans, Apple’s own Rails developer page seems to think it’s okay, and others suggest these issues may have been fixed by 10.5.7.

Do gem list --local to see the full list from both locations. If you just want to see what you’ve installed, type
cd /Library/Ruby/Gems/1.8
then (e.g.)
ls -al
to check the new files after each new gem install. For documentation on the gems you’ve installed (including Camping), type gem server and visit http://localhost:8808/ (after updates, hit ctrl Z to stop gem server or close the terminal window, then launch it again).

Install Camping and what it needs

Install Camping and what it needs

gem dependency camping shows that Camping requires only Rack >= 0.3 and (for generating HTML) markaby >= 0.5, so install Rack, Markaby and Camping:
sudo gem install rack
sudo gem install markaby
sudo gem install camping

You might also want to update the Leopard versions of Mongrel and Rake and, for using databases, ActiveRecord and sqlite3-ruby:
sudo gem update mongrel
sudo gem update rake
sudo gem update activerecord
sudo gem update sqlite3-ruby

These (including the updates) will be installed in /Library/Ruby/Gems/1.8

When updating sqlite3-ruby you may see lots of lines starting "No definition for " which indicates missing documentation, but the gem will still work.

You can now go Camping in Leopard. To stop the Camping test server, Mongrel, without closing the Terminal window press ctrl C.