How to install rbenv

rbenv seems to be the preferred tool currently to create and maintain a Ruby environment. It helps install and maintain any version of the Ruby interpreter and other tools. Ubuntu ships with ancient versions of rbenv, so it is not recommended to try that. Instead, installing its source from Github and keeping it updated using Git seems to be the preferred method.

Installing rbenv

  • Checkout the latest source code of rbenv into ~/.rbenv. This is the directory where all the programs and files that it uses and maintains will be stored:
$ git clone ~/.rbenv
  • Add the path that contains rbenv binary to your PATH environment variable:
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
  • Enable rbenv to be called whenever a shell is opened so that it can setup the environment:
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
  • Restart your shell and check if rbenv can execute:
$ exec $SHELL
$ rbenv
  • To be able to install the Ruby interpreter, we also need the ruby-build plugin for rbenv. This can be installed by:
$ git clone ~/.rbenv/plugins/ruby-build
  • Once ruby-build is added, you can list what can be installed using rbenv install -l and install it using rbenv install.

Updating rbenv

Just update from Github:

$ cd ~/.rbenv
$ git pull

Tried with: rbenv 0.4.0 and Ubuntu 14.04

2 thoughts on “How to install rbenv”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s