From charlesreid1

Notes on installing Ruby.

These notes should be followed before trying to install anything else, like Octopress.

Linux

I wanted to install this on my Netbook running Ubuntu 12.04. I read that Ruby 1.9 had some serious flaws (just hearsay), so I'm using 2.0, specifically ruby 2.0.0p247. That means YOU CANNOT USE THE rbenv AND ruby-build IN THE APTITUDE REPOSITORIES!

You need the bleeding edge stuff. Specifically, bleeding-edge two things:

  • rbenv
  • ruby-build

rbenv

There are a lot of different versions of ruby out there. Various versions have various uses, but this leads to some version confusion. What we'll do is use a program called rbenv (ruby environment - get it?) to manage our ruby installation and its corresponding gems (gems are like ruby packages).

First, I installed rbenv from sstephenson on GitHub:

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc

When you start a new shell, you should be able to type

type rbenv

and see:

rbenv is a function
rbenv ()
{
[...]

YAAAYYYY!!!

ruby-build

The ruby-build package will instruct rbenv where to find various versions of ruby and how to build them.

Next, install ruby-build from sstephenson,

git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

And now you should be able to use ruby-build to access various Ruby builds, which you can install and manage with rbenv.

Installing the Ruby Version You Want

Now all that's left is to install Ruby 2.0 using rbenv:

rbenv install 2.0.0-p247

This will take a while. If it looks unresponsive, just pop open another tab and run "top". You'll see either the C compiler or a ruby process cranking away on the CPU until its done.

Once you've installed your version, you gotta pick which version is going to be your main ruby version.

First, see if there's already a ruby (maybe a system ruby? old crusty ruby? who knows):

which ruby
ruby --version

Who cares about that. Let's use our own damn rbenv Ruby!!!

Wait, what Ruby versions do we have?

rbenv versions

Oh, yeah, of course. Let's use Ruby 2.0.0-p247, which should have been listed in the output of the command above:

rbenv local 2.0.0-p247

Now we have our correct version of Ruby (2.0.0-p247) set. Voila!


Mac OS X

Either follow the above instructions to install rbenv and ruby-build on mac, or just use Homebrew:

brew update
brew install rbenv
brew install ruby-build