Clean install of Ruby on Rails on Mac OS X
I’m going to buy a Mac Mini today, and this is the process I’m going to follow to make a clean install of Ruby on Rails. I’ll refine these instructions as I walk through them.
- Install Xcode from the Mac App Store. If you have Lion, it’s a free download. Xcode comes with all of the code compiling utilities that allow us to build our rubies (“rubies” are a specific version of ruby) and gems (ruby frameworks). It can also be installed from Apple Developer Connection, but that’s the hard way. If you download it from the Mac App Store, you’ve actually only downloaded the installer, so go ahead and install it.
- Open Terminal.app, and visit Begin Rescue End and copy their one-liner to install RVM, the Ruby Version Manager. Pasting this line into a terminal will run RVM’s installer.
- Read the instructions on your screen. There will be a line of “shell script” you need. Copy this line (just as you would in any Mac app), and then type
open -a TextEdit .bash_profile, paste it, and save. - Close your terminal and re-open it to make sure your environment is up-to-date.
- Type
time rvm install 1.9.3 --with-gcc=clangto install Ruby 1.9.3, the latest and greatest version of Ruby. I like to use the time command to tell me how long it took, but you don’t have to. - You don’t usually need the with-gcc argument, but at the time of this writing, the 1.9.3 packaging is behaving weird on Lion. Normally, you could just do
rvm install 1.9.2. That ruby is still rather popular, so you should install that now. - Type
rvm use 1.9.3 --defaultto make Ruby 1.9.3 your default ruby, and the one that will be used when you typeruby. - Type
gem install bundler. A lot of tutorials will say to type ‘sudo before ‘gem. If you do this, the gem will be installed for use with your “system ruby”, which you do not want to use, and won’t be visible to your RVM ruby. - Type
gem install rails. Rails is actually a gem, just another framework on Ruby. - Gem is pretty smart about handling dependencies, and right now you’re set to start Rails development. There are a few more gems that aren’t explicit dependencies of Rails, but that you’ll still need. To install the remaining essential gems, start a new project.
rails new my_awesome_project; cd my_awesome_project. The last command Rails runs when making a new project isbundle install, which is the command to install all the gems your project requires. You’re now completely installed. - Enjoy! You should now follow Michael Hartl’s Rails Tutorial and find web development enjoyable again.