7 months ago
Friday, October 5, 2007
I Am Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X — Automatically (And So Can You!)
Update: This script has been given a permanent home in the Sakuzaku Goodie Basket. Please head over there to get the latest documentation for it.
Here’s a script to automatically download, build, and install the OS X versions of the following software:
- Readline (5.2)
- Ruby (1.8.6)
- Rubygems (0.9.4)
- Subversion (1.4.5)
- MySQL (5.0.45)
- Rails (latest version)
- Mongrel (latest version)
- Capistrano (latest version)
The steps it takes mirror those explained in Hivelogic’s great post Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X. If you’re of the variety that can’t easily understand the instructions in HiveLogic’s post (for some reason your humorless software-engineer–partner insists you run the Rails app on your local machine for development), or if you’re the variety that has to do this installation samba prance dance on a frequent basis, then this might come in handy for you.
Notes
- Before you run the script, you’ll need to have Xcode installed. Unfortunately, I can’t make the script download and install it automatically, since you need to login to with an ADC account to download it. It’s an almost 1 GB download, so plan accordingly. But real developers have Xcode installed, so it’s OK.
- While installing the gems, you’ll probably be prompted to choose which version to install for a number of the gems. Choose the option for the highest Ruby version listed (i.e., not the ‘mswin32’ version).
- If the script complains when installing the MySQL gem, see our post about Installing the Ruby mysql-2.7 gem on OS X 10.4.
- Since you can only really run this script once, I have only tested it a few times, on a Powermac and a few MacBook Pros running OS X 10.4.10. If you run into any problems, send me a bug report so I can improve the script.
There’s no easy way to make the script automatically download the latest versions of the software involved (except for the gems), so I’ll try to keep the script up-to-date as new versions of the software it installs are released. (If I fall behind, just email me and I’ll post an update, and maybe send you a Sakuzaku pin badge.)
Download
Usage
- Open Terminal.
- Type:
bash /directory/where/i/downloaded/the/file/install.sh
Sudo will prompt you for your administrator password after you run the script, and then blast off with a flurry of downloading and compiling. You’ll have to do some clickety-clicking to help MySQL install itself. Then sit back — you just saved 15 minutes (or 4 hours).













RSS Feed
Tyler
Thursday, October 11, 2007
10:24 am
An indispensable script for anyone developing Rails apps on a Mac. You’ve saved me hours! Thanks so much for sharing.
Dan Benjamin
Saturday, October 13, 2007
3:57 pm
I’ve resisted doing this for years because, should there be an error, or even a misconfiguration, the user wouldn’t know about it.
In any case, nice work - but you should mention and link to Hivelogic correctly - there is no capital L in Hivelogic.
Cody
Saturday, October 13, 2007
3:58 pm
So running the commands one by one avoids misconfigurations how? The script dumps the build output, but all the same, it’s not very useful regardless of whether you run the commands one by one or have a script run them for you. After building Ruby the very last few things you get are a bunch of ominous warnings from the linker. If I were someone doing this for the first time, the build output is really ambiguous as to whether there’s a problem or not. The only way I ever really discover something wasn’t installed right or was misconfigured is when I actually go to use it and see it doesn’t work.
And a script doesn’t make it any less useful to someone who already knows what they’re doing and doesn’t want to sit there for an hour waiting for each build to finish before typing in the next command.
Dan Benjamin
Saturday, October 13, 2007
4:00 pm
That’s a valid point, but, say there is an error somewhere along the way, and that section fails. Will your script stop and let you know, or will it continue? If you’ve walked away, will you see that something has failed later, without testing?
And say you fix the part that did fail … won’t you have to re-run through the script again, just to get to the part that has failed?
In any case, all I’m saying is, there are potential problems when trying to write a script that will work for all users in every situation.
Many people, perhaps a dozen or so, have written scripts like this and sent them to me, and I’m certainly not discouraging you to do so. The opposite is true - I’d love to see an intelligent, error-detecting script that could make this whole process easier. Just keep in mind that there may be some pitfalls, and that I didn’t offer a script publicly because, over the years, I haven’t been able to ensure that it will “just work” the way a script on a Mac should!
Graham Siener
Monday, October 15, 2007
8:55 am
I used the script the other day and it worked just fine. I didn’t set up MySQL but installed everything else and all systems are go.
FWIW I’m on a Macbook running 10.4.10.
Thanks for your work!
Chuck
Friday, November 2, 2007
12:00 pm
This is great, thanks for posting this!
I have one question though, after running this script, and verifying that readline and ruby appeared to install correctly, the version of ruby on my machine still states 1.8.2, not 1.8.6 (ruby -v). Is this normal? Is there a different way to confirm which ruby version is installed.
One thing I noticed when the make install was completed for readline, the last line stated, if this is any clue:
install: you may need to run ldconfig
Thanks again!
Cody Robbins
Friday, November 2, 2007
11:55 pm
@Chuck: Did you open up a new Terminal window? The window you were running the commands in should still be finding the previous version of Ruby. If a new window doesn’t solve the problem, then you might need to add
/usr/local/binto your path in your shell init script.I think the warning at the end of the
readlineinstall is probably normal.Chuck
Sunday, November 4, 2007
11:19 am
Ok, so I did add the “/usr/local/bin” to the PATH in my system init profile in /etc, see below, but it still comes up with the
Ruby version 1.8.2. I restarted my computer, as well. What am I doing wrong?
# System-wide .profile for sh(1) PATH="/bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin" export PATH if [ "${BASH-no}" != "no" ]; then [ -r /etc/bashrc ] && . /etc/bashrc fiCody Robbins
Sunday, November 4, 2007
11:58 am
@Chuck: I think you’re missing the
/at the beginning of the/usr/local/bin. Is that it?Chuck
Sunday, November 4, 2007
7:41 pm
You’re right! But I just went to the /usr/ocal/bin directory where the ruby command exists, and ran the same “ruby -v” command and it was still listed as 1.8.2. Do I need to be logged in as root in order for this to work? Does it matter the version of XCode, I’m using 2.2?
Cody Robbins
Sunday, November 4, 2007
7:44 pm
@Chuck: If you change to the
/usr/local/bindirectory you’ll have to runinstead of just
to force it to use the binary in that directory. Did you do that?
You shouldn’t need to be logged in as root to do it — the install script used sudo, so it should have asked for your password and installed all the software as root when you ran it.
Jeffrey McGough
Thursday, January 3, 2008
5:38 pm
Chuck,
You have a PATH problem, if you check the hivelogic article, you will see a section on paths.
The system looks for where to search for executables based on the order of the $PATH variable.
In your example above the system will look in /usr/local/bin last. So it would find the ruby that came with OS X in /usr/bin first.
This is why you always got the old version information anytime you ran “ruby -v”.
The hivelogic article section on paths can help you fix this.
Hope this helps.