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.
11 Comments
Thanks, worked flawless.
I found the support in NetBeans 6 for Ruby development, to be excellent. An easy download as well < 20 MB.
Thank you. You just ended a two day hair pulling session now that IRB works again!
I’m sending you a bottle of bourbon.
Thank you so much for this!
Caveat–I don’t seem to be able to access chopine.be . Is anyone else seeing this, and if so, are there any mirrors where I can find the patches in question?
Molly
Your welcome and that domain (chopine.be) appears to be back up now.
Thanks for posting this! This saved me from ruby/readline hell.
These instructions are still saving people’s irb skin, BTW! I upgraded my /usr/local/ ruby to 1.8.6-p114, and I did apparently have to apply the readline patches, as well as all of Laurent Sansonetti’s patches.
However, curl was just returning html 404s which of course reported garbage input when piped to the patch command. So I open all the diff files (mate *.diff), followed the links manually in my browser, copied and pasted the diff text over, and applied all the patches.
I got my IRB back! Thanks a ton.
Of course, require ‘osx/cocoa’ still doesn’t work, but I guess that’s another adventure!
Firstly, a big thank you to Michael Biven for taking the time to share this solution to the installation of Rails et.al and of course many kudos to Dan Benjamin for his generous dedication to benefit the open source aficionados, especially for novices like me.
I had some trouble with one of the http://chopine.be/lrz/ruby-osx-patches/etc-irbrc.diff | patch -p0 patch and I’m wondering if RYAN RICKERTS could please explain how he copied the text and how he saved it. This is the only thing that did not work for me.
Notwithstanding my inability to patch that one file, I proceeded to make and install the Ruby 1.8.6 application. I wonder how critical that patch will be and what could happen if it ’s never corrected and “re-maked”. Is it important to recompile Ruby once I manage to get that file properly patched?
Any suggestions or alternatives would be very much appreciated!
Thanks so much for tracking down these loose ends. My IRB is back!
Thanks. This was super smooth & straightforward. It was very helpful
I’m having trouble with the very first step of Dan’s instructions.
Last login: Sat Sep 20 02:03:10 on ttys000
laurence-browns-macbook:~ LPB$ wrangler ~/.bash_login
-bash: wrangler: command not found
laurence-browns-macbook:~ LPB$
One Trackback
[...] 5.2 at the time of writing) at GNU.org. You may have to apply the following patch. Thanks to Michael Biven for showing a nice simple way to do this from the command [...]