Advertisement

Ruby on Rails

Installing Ruby on Rails on Mac OSX Platform

Mac OSX | Ruby | Ruby On Rails | Xcode

Learn Ruby on Rails

Advertisement

This entry is part 2 of 4 in the series Learning Ruby on Rails From Scretch

Installing Ruby on Rails is one of the hardest things for a newbie to Ruby and Ruby on Rails. Rails is an open source project with lots of dependencies which makes great strength for Rails and allows it to initiate quickly, but it has the drawback of making a developer pass through lots of difficulties in installing ruby on rails, particularly for someone new to programming or new to the MAC world.

Installing Ruby on Rails

I had to modify some of the instructions over the tutorial of installing Ruby on Rails on different Macs with different versions of OS X and XCode. Here is what worked for me on Mountain Lion and XCode 4.x.x. But first lets familiar with a couple of terms.

  • XCode is Apple’s iOS & Mac Apps development environment, but it includes some system libraries that you need for installing Ruby on Rails.
  • RVM (Ruby Version Manager) is highly recommended as it lets you manage different versions of Ruby, Rails and Gems so you can try out new versions or mimic different production environments without having to install/reinstall everything.
  • Homebrew is a package environment for OS X that can install most other missing system packages you’ll need for installing Ruby on Rails.

Installing Ruby on Rails

Installing XCode:

  • Click and install XCode from the Mac Store
  • Once installed, go to Preferences -> Downloads -> Install Command Line Tools

Please note that the next several installation commands should be run in the Terminal application.

Install Homebrew and apple-gcc42
This installs the Homebrew package manager and a GCC compiler

Install RVM:
In the OS X Terminal, issue the following commands:

Note: run the source command outputted from the above command

 

 

The above commands install RVM, install ruby version 1.9.3, tell RVM to use the 1.9.3 version for the rest of the stuff you’ll install and set 1.9.3 to be default going forward.

Install XQuartz

NOTE: This step is optional and is only necessary if you plan to do image manipulation using ImageMagick.

Apple no longer ships an X Windowing system starting with Mountain Lion, so you’ll probably need to install the open sourced version of this available at  http://xquartz.macosforge.org/landing/

Install Rails

Get Ready for most important step of installing Ruby on Rails. to do that you just have to type following command on terminal.

Rails should now be installed. To create a test app, run

If you get an error about OpenSSL support, you may need to update RVM. See the instructions at https://rvm.io/packages/openssl

Optional: MySQL
MySQL is a popular open source database that you may want to install locally to make sure that it behaves the same as your production instance of MySQL (if that’s what you’re running). Rails abstracts a lot of the different database differences to your app, but you still may want to actually run MySQL just to have the added confidence that there aren’t any subtle quirks/differences.

If you want to have MySQL start automatically when your Mac logs in, you can set it up like this:

Optional: ImageMagick

  • I had to do some basic image manipulation in my app (resizing photos, etc) and I had to install the ImageMagick package through homebrew to get it working.

Done! I had to try a lot of combinations to get it working on my laptop. hopefully this helps as most of the online resources I found were out of date for Mountain Lion or the newest version of XCode.

For more updates on Programming visit our FB Page.

 

Series Navigation<< Create Ruby on Rails Project from Scratch, a beginner’s guideRuby on Rails Render Template & Pass Data to View >>

Bookmark Link using: bookmark at folkd