Install Homebrew

. Install Xcode and the Command Line Tools

If you don't have it installed I suggest you install Xcode from the Mac App Store and install the command line tools in Xcode Preferences -> Downloads.

Otherwise if you don't want to do that you can download the Xcode standalone command line tools for Mountain Lion at https://developer.apple.com/downloads/index.action (Note: You will have to login with your Apple Id.).

2. Install Homebrew

  1. ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Now run:

  1. brew doctor

If you get the error:

  1. Error: No such file or directory - /usr/local/Cellar

Run the following:

  1. sudo mkdir /usr/local/Cellar

and

  1. sudo chown -R `whoami` /usr/local

3. Install RVM

  1. curl -L get.rvm.io | bash

After this is complete execute the following in order to use RVM in your current shell:

  1. source ~/.rvm/scripts/rvm

4. Add the following to your ~/.profile in order to source RVM everytime you run Terminal.app:

  1. [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

5. Check RVM Requirements

  1. rvm requirements

Note the "Missing required packages: ..." statement. 

If you have any missing required packages you will need to install them before continuing by running brew install <missing package name>.

For example, here is the output I had:

  1. $ rvm requirements
  2. Installing requirements for osx/10.8/x86_64, might require sudo password
  3. Skipping `brew update` make sure your formulas are up to date.Missing required packages: autoconf, automake, libtool, pkg-config, apple-gcc42, libyaml, readline, libxml2, libxslt, libksba, openssl, sqlite.
  4. /Users/christopherkaukis/.rvm/scripts/functions/requirements/osx_brew: line 61:
  5. /usr/local/Cellar/openssl/1.0.1e/bin/openssl: No such file or directory
  6. /Users/christopherkaukis/.rvm/scripts/functions/requirements/osx_brew: line 63: /cert.pem: Permission denied
  7. /Users/christopherkaukis/.rvm/scripts/functions/requirements/osx_brew: line 64: /cert.pem: Permission denied
  8. /Users/christopherkaukis/.rvm/scripts/functions/requirements/osx_brew: line 65: /usr/local/Cellar/openssl/1.0.1e/bin/c_rehash: No such file or directory

If you need to install apple-gcc42 and get an error:

  1. Error: No available formula for apple-gcc42

Run the following:

  1. brew tap homebrew/dupes

If you get an error after running this:

  1. Error: Already tapped!

Run the following instead to repair:

  1. brew tap --repair homebrew/dupes

Now you can continue and install apple-gcc42:

From the "Missing required packages: ..." line above, for example I can now execute the following:

  1. brew install autoconf automake libtool pkg-config apple-gcc42 libyaml readline libxml2 libxslt libksba openssl sqlite

 

6. Run brew doctor again to make sure everything checks out

Execute the following:

  1. brew doctor

If you get an error or warning about your PATH. Such as:

  1. Warning: /usr/bin occurs before /usr/local/bin

Open your ~/.profile and add the following line to the top (or bottom, it shouldn't matter):

  1. export PATH=/usr/local/bin:$PATH

Run brew doctor to check all is swell before continuing.

7. It's now time to install Ruby 2.0.0:

First run the following commands:

  1. rvm get head

followed by:

  1. rvm requirements

If you don't get any errors you can finally install Ruby 2.0.0:

  1. rvm install 2.0.0

To set as your current version of Ruby run the following command:

  1. rvm use 2.0.0

To make it the default Ruby:

  1. rvm default 2.0.0

or 

  1. rvm use 2.0.0 --default

Now every time you open Terminal.app Ruby 2.0.0 will be default. You can always check which version of Ruby you have using the following command:

  1. ruby -v

and where it's located executing the command:

  1. which ruby

I hope this tutorial was useful. You are now setup to run Ruby 2.0.0 on Mac OS X 10.8 Mountain Lion. Shall you have any issues post a comment below and I'll try and help you out.

- Chris

posted @ 2014-11-21 15:44  火红的云彩  阅读(597)  评论(0编辑  收藏  举报