Jer on Rails

Jeremy Weiskotten on web development, startups, beer, and other stuff.


Setting up a Rails development environment on Leopard

I recently set up a new Rails environment on Mac OS X 10.5 (Leopard). I googled for various bits and pieces. I have no idea how much of this translates to 10.6 (Snow Leopard).

I leaned on MacPorts to install Git, Ruby, RubyGems, PostgreSQL, and some other stuff that my Rails work depends on.

Xcode and MacPorts

  1. Install Xcode from OSX DVD.
  2. Install MacPorts via http://www.macports.org/install.php

Git

  1. sudo port install git-core +svn+bash_completion+doc

To configure Git, including some handy aliases, add the following to ~/.gitconfig:

[user]
email = {your@email.com}
name = {Your Name}
[core]
editor = mate -w
[color]
status = auto
diff = auto
branch = auto
[alias]
co = checkout
st = status
ci = commit
df = !git diff | mate
[push]
default = tracking

To enable bash_completion, add the following lines to the end of your .bash_profile or .profile:

if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi

Ruby 1.8.7 and RubyGems

  1. sudo port install ruby
  2. sudo port install rb-rubygems

(Note that gems will be installed to /opt/local/lib/ruby/gems/1.8.)

Symlink /usr/local/bin/ruby to MacPorts install

  1. sudo ln -s /opt/local/bin/ruby /usr/local/bin/ruby

ImageMagick and RMagick
http://rmagick.rubyforge.org/install-osx.html

  1. sudo port install imagemagick +gs +q16
  2. sudo gem install rmagick

PostgreSQL 8.3
http://shifteleven.com/articles/2008/03/21/installing-postgresql-on-leopard-using-macports

  1. sudo port install postgresql83 postgresql83-server
  2. sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb
  3. sudo chown postgres:postgres /opt/local/var/db/postgresql83/defaultdb
  4. sudo su postgres -c ‘/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb’

And so that pg server launches at system startup…

  1. sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql83-server.plist

PostgreSQL Ruby adapter

  1. sudo env ARCHFLAGS=”-arch i386″ gem install postgres — –with-pgsql-lib=/opt/local/lib/postgresql83 –with-pgsql-include=/opt/local/include/postgresql83

Sphinx

  1. sudo port install sphinx +postgresql83

Common gems

  1. sudo gem install rails fastercsv redgreen git_remote_branch capistrano capistrano-ext ruby-debug ruby-prof sqlite3-ruby

SSH key

  1. ssh-keygen (Enter to select all defaults)
  2. Add public key to GitHub account.

Tags: , , ,

One Comment

  1. On November 24th, 2009 at 2:54 pm Jeremy Weiskotten said:

    http://gist.github.com/241915

    My .profile