You want to work with Ruby on Mac OS X, but the version already installed on the system is too old for your needs.
It is not a good idea to upgrade the version installed by Apple, as it is there for their own purposes and it’s best to leave it alone. Instead, use rbenv to install sandboxed versions of Ruby in your own home directory.
So, use Homebrew to install rbenv and ruby-build (a rbenv plugin for easily installing different Ruby versions) in your system:
$ brew update
$ brew install rbenv
$ brew install ruby-build
As instructed by rbenv, also add the following line to your profile (e.g. ~/.bash_profile
):
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
Restart your terminal or source ~/.bash_profile
before continuing.
Figure out the latest stable version of Ruby—at the time of writing it’s 2.0.0-p247
—and install that version:
$ rbenv install 2.0.0-p247
$ rbenv rehash
$ rbenv global 2.0.0-p247
And you should be good to go. Remember to run rbenv rehash
after installing any gems that provide commands.