Installing rbenv, ruby and rails

rbenv can be used to install and manage several versions of ruby and corresponding gems. An alternative would be to use RVM.

Initial Setup

Install rbenv into your home

git clone git:// ~/.rbenv

Install ruby-build to allow building ruby versions from source with rbenv install

git clone git:// ~/.rbenv/plugins/ruby-build

Optionally install rbenv-bundler to avoid typing bundle exec to call gem binaries

git clone git:// ~/.rbenv/plugins/bundler

Activate rbenv

export PATH="$HOME/.rbenv/bin:$PATH"; eval "$(rbenv init -)"

If you regularly need rbenv, you may want to put the above line in your shell config.

Manage ruby version

rbenv install --list        # list available versions
rbenv install 1.9.3-p448    # install a specific version of ruby
rbenv versions              # show installed versions
rbenv global 1.9.3-p448     # enable this version globally
rbenv rehash                # update shim executables
ruby --version              # should now show the correct version

Manage gems using bundler

gem install bundler         # install bundler to manage gems
bundle                      # install all gems required by your local Gemfile