Installing Ruby on Rails on Mac OS 10.5 or patching Dan Benjamin’s guide (Put together quickly (Haligan)) by michaelb
Update: Dan has posted his updated guide for installing Ruby on Rails on Leopard.
I don’t think there are too many people who hasn’t come across either of Dan Benjamin’s guides when looking to install Ruby on Rails on a Mac. They are simple, to the point and you could basically copy and paste to get Ruby, Rails, MySQL and depending on which guide either Mongrel or LightTPD installed, but since the release of Leopard the instructions if unaltered would fail when installing Readline, Ruby and Subversion. Dan has mentioned that he will be providing an update to the guide for Leopard users, but with a new baby and job it might (and justifiably so) be a bit before he has the chance to finish them. What I’m going to cover are the additional steps I added to Dan’s guide to get everything up and running for me. First thing to do is read his guide making sure to note the following sections: What’s needed (except we are using OS 10.5 and Xcode 3.0), bash, Quick Warning, sudo and paths. To get the parts of Dan’s guide that would fail to work we will be applying some patches to Readline, Ruby and Subversion. If you are uncomfortable with this then I would suggest that you wait for his updated guide. And if you haven’t already tried installing the unaltered version on Leopard, consider running through each step to see the error before and after the patches. And remember just as he points out himself these instructions are completely use at your own risk and I do not take responsibility for anything resulting from following them.
Before you begin
Make sure to follow the steps from his guide to install Xcode, update your path and create the directory at /usr/local/src if you have not already done so.
Ruby
If you have tried his guide while using Leopard you probably got stuck at the first step when trying to compile readline. You will need to apply a patch from the developers, because the unpatched version of readline checks for the version of the operating system but does not include darwin9 (Leopard) in it’s list. We will be applying a patch to the file support/shobj-conf located in the readline-5.2 directory in /usr/local/src/ and then we can compile it without getting an error. You should also notice that we are installing the latest stable version.
curl -O ftp://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz
tar xzvf readline-5.2.tar.gz
cd readline-5.2
curl -O http://ftp.gnu.org/gnu/readline/readline-5.2-patches/readline52-012
patch -p0 < readline52-012
./configure --prefix=/usr/local
make
sudo make install
cd ..
And now on to installing Ruby. While looking into why Ruby would segfault during the install I came across Laurent Sansonetti’s explanation and the set of patches that are applied to Ruby by Apple for the version that Mac OS ships with.
curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz
tar xzvf ruby-1.8.6-p111.tar.gz
cd ruby-1.8.6-p111
curl http://chopine.be/lrz/ruby-osx-patches/dot-darwin.diff | patch -p0
curl http://chopine.be/lrz/ruby-osx-patches/etc-irbrc.diff | patch -p0
curl http://chopine.be/lrz/ruby-osx-patches/ignore-gsetcontext.diff | patch -p0
curl http://chopine.be/lrz/ruby-osx-patches/md5_sha1_commoncrypto.diff | patch -p0
curl http://chopine.be/lrz/ruby-osx-patches/use-dyld.diff | patch -p0
curl http://chopine.be/lrz/ruby-osx-patches/use-setreugid.diff | patch -p0
curl http://chopine.be/lrz/ruby-osx-patches/words-bigendian-from-arch.diff | patch -p0
./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local --enable-shared
make
sudo make install
sudo make install-doc
cd ..
RubyGems
Only change here is using the current version.
curl -O http://files.rubyforge.mmmultiworks.com/rubygems/rubygems-1.0.1.tgz
tar xzvf rubygems-1.0.1.tgz
cd rubygems-1.0.1
sudo /usr/local/bin/ruby setup.rb
cd ..
Ruby on Rails
sudo gem install rails --include-dependencies
Remember one change in Rails 2.0.2 is that SQLite3 is now the default database. When you followed Dan’s instructions and changed the path you lost the SQLite3 bindings for Rails that Leopard ships with so we need to add them back.
gem install sqlite3-ruby
Mongrel
Just like RubyGems no changes here except it will be grabbing the latest version.
sudo gem install mongrel --include-dependencies
Subversion
This would be the next step that you should see an error while following the unaltered guide. I came across a patch from Brian D. Wells that allowed for me to complete the install.
curl -O http://subversion.tigris.org/downloads/subversion-1.4.6.tar.gz
curl -O http://subversion.tigris.org/downloads/subversion-deps-1.4.6.tar.gz
tar xzvf subversion-1.4.6.tar.gz
tar xzvf subversion-deps-1.4.6.tar.gz
cd subversion-1.4.6
curl -O http://homepage.mac.com/brianwells/.Public/apr_darwin_smb_patch
patch -d apr -p0 <apr_darwin_smb_patch
./configure --prefix=/usr/local --with-openssl --with-ssl --with-zlib
Edit the file /usr/local/src/subversion-1.4.6/apr/include/apr.h
Changing the line #define APR_HAS_SENDFILE 1 to #define APR_HAS_SENDFILE 0
make
sudo make install
cd ..
Capistrano
sudo gem install capistrano --include-dependencies
sudo gem install termios --include-dependencies
MySQL
And finally we’re ready to follow Dan’s instructions to install MySQL.
Alternatives
A big thanks to Dan for creating each of these guides and keeping them updated over the years. I hope you find these additions useful and remember usually there are a few different alternatives to doing something.