This is part of an on-going series of posts on learning Ruby on Rails. It’s a bit technical but not too much so. If you’re interested in startups and are a “business guy” it definitely wouldn’t hurt to understand everything I write here, as I’m pretty much a total noob, but was willing to learn. Enjoy!
While Ruby on Rails prides itself on requiring few dependencies, there are still a couple of things you need to install/setup in order to actually start doing anything in Rails.
- Xcode Tools (the Apple developer toolkit)
- Ruby (the most up-to-date version)
- Ruby Gems (the package manager)
- Rails (the framework itself)
- Sqlite (one of the preferred database engines)
While there are apparently some auto-installers out there, I chose to use Hivelogic’s guide to installing Ruby – which is also referenced as a guide from the official Ruby on Rails site. I figured I’d do things manually so I could better understand what was going on – also none of three I looked at (Locomotive, MacPorts, Finks) seemed that very user-friendly, so might as well go with the pure install.
Note: In hindsight, I probably would have used the setup recommended by the Ruby section on About.com – it makes you install RVM (Ruby Version Manager) and Git but still it looks pretty easy.
What ended up happening was that things were a little bit trickier than I anticipated, and also because it is still so new, some stuff in Rails 3 wasn’t working exactly right, so it took roughly 4 hours for me and I’m still not 100% convinced I did it right. But anyway, here’s how it went:
If you want to install Ruby from the source code like I did, you need a copy of Apple’s Developer Tools – they are called, unsurprisingly, Xcode Tools. You can get them for free from your OSX CD that came with your Mac or you can register on Apple’s Developer Network for $99/year to download it online. It’s a big download (~800 megs).
I didn’t get this at first and was really frustrated for a while, as you by this tweet:
If you are using RVM or some other port, I think you can skip this step…
Installing the latest version of Ruby
Ruby is an object oriented scripting language that the Rails framework is built on top of. I’m running OSX 10.6 (Snow Leopard) which comes with Ruby 1.8.7 , which is good enough to run Rails 3, but not preferred. Snow Leopard also comes with Rails 2.3.5, which you’ll also have to update (duh) in order to run Rails 3.0.0.
Following HiveLogic’s commands, I first create a local path to install Ruby in. He has you doing some stuff with Textmate  but I don’t have it so I use TextWrangler to do it in a less fancy way – just save the file as “.profile” and you’ll be fine.
Navigate yourself in to the directory Make sure to update the URLs he has you entering so you are getting the latest versions of Ruby and Ruby Gems. For me this meant punching in:
curl -O ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p0.tar.gz curl -O http://rubygems.org/pages/download
Then you run the fancy Terminal code that Hivelogic gives you and it installs Ruby and Ruby Gems.
After all that work to set things up, it was time to actually install Rails. It looks easy on paper – according to the official website:
Sadly, when I originally did this, all I got was an error message that read: “ERROR: While executing gem … (Gem::FilePermissionError) You don’t have write permissions into the /usr/local/lib/ruby/gems/1.9.1 directory.”
Frustrating right? But then … there was a glorious moment when the heavens opened up and Randall Monroe spoke to me: saying
JASON, I GRANT YOU THE POWER OF SUUUUUDDOOOOO!
And of course, how could I forget “Sudo make me a sandwich”!
And thus I punched in:
sudo gem install rails
and BAM! Tons of lines started flooding down the Terminal as Ruby on Rails 3.0.0 got installed on my computer by using sudo . I was thrilled:
“gem install rails”. What? No write permissions into this directory? How about “SUDO gem install rails”? YEAH, THAT’S RIGHT. #learningrails via web
All that was left was to install sqlite3, which apparently is the standard database engine for Rails 2.0 and onward. I wanted thew newest version and what I was told to punch in:
gem install sqlite3-ruby
gave me a nasty error: “Building native extensions. This could take a while… ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension.”
So I googled it and it’s a pretty common problem – google even suggests “sqlite3-ruby error” when you type in “sqlite”. I found this error filed as a ticket on RubyForge, (which apparently was updated as “resolved” in June of 2009 even though it still didn’t work for me!).
I ended up using the workaround suggested by the same guy who filed the ticket “Nobody”. Thanks dude. Apparently, installing an (older? different?) version of sqlite does the trick:
gem install --version 1.2.3 sqlite3-ruby
#EDIT – So in a lot of stuff you do later on with Rails you’ll be using “bundle install” to pre-load a bunch of gems. However, for some reason, every time I create a new app, the Gemfile in the app that bundle works off of always tries to install the newest version of sqlite3 so I get that error I note above all the time. So here’s my work around – adding this piece of code into the Gemfile.
gem sqlite3-ruby', '1.2.3'
So there you have it. My long, convoluted journey to installing Ruby on Rails 3.0.0 as pretty much a total noob. It took a while, but I definitely learned some stuff and feel pretty good about myself. My final tweet on this topic:
You can learn more about my adventures with Ruby on Rails here.
 You can tell which version of Ruby you are running by using the program Terminal (look it up in Spotlight). Give it a second to load until you see something like
Then type “ruby -v”. Apparently when placed behind certain programs “-v” command tells you what version of the program you are running. You can also do use “rails -v” to see what version of Rails you are running.
 According to “edaddresse” of Yahoo Answers:
“sudo” is a command commonly found in unix-like operating systems. It allows a normal user (without elevated rights on the system) to execute privileged commands. For example “sudo make install” execute the “make install” with administrator rights, so to say, so that a program install may take place.
“sudo make me a sandwich” comes from the *excellent* xkcd site (http://xkcd.com/149/). One character asks the other to make him a sandwich, a request ignored at first. The character then asks again, but using the “sudo” command to get elevated privileges in asking for a sandwich, which seems to work.
Latest posts by Jason Shen (see all)
- No Better Than Adversity - November 14, 2017
- Building a Product as a Solo Technical Founder with Safia Abdalla - September 25, 2017
- Three Product Management Announcements - September 16, 2017