Tag Archives: rbenv

Installing Rbenv

RBENV is a Ruby Version manager like RVM. Despite that I’ve been working long time with RVM and it is great, I am giving an opportunity to RBENV. Some reasons:

  • Lighter and more comprehensive to install
  • Simpler, if you use Bundler (I do) you would avoid gemset management

First is install requirements. I’ve got it from RVM, but finally I’ve found that I’ve needed when ruby versions are compiling:

sudo apt-get -y install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison libcurl3 libcurl3-gnutls libcurl4-openssl-dev

Install RBENV:

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

RUBY-BUILD provides an ‘rbenv install’ command to compile and install different versions of Ruby on UNIX-like systems.

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc

REHASH avoids use this command every time a gem is installed or uninstalled.

git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash

BINSTUBS avoid the use of ‘bundle exec’ in some commands which should be executed in command line:

git clone https://github.com/ianheggie/rbenv-binstubs.git ~/.rbenv/plugins/rbenv-binstubs

The only disadvantage of BINSTUBS is that you have to remember to run the following command

bundle install --binstubs .bundle/bin

in all your actual projects, so that the appropriate bundle version will be accessed. Binstubs will be created at .bundle/bin and won’t interfere with ./bin folder.

Now, you can use it. List all available versions:

rbenv install -l

Install a Ruby version:

rbenv install 2.1.2

Choose default ruby version on your system

rbenv global 2.1.2

Choose default ruby version on your project (this will create a .ruby-version file scanned every time you access the folder)

rbenv local 2.1.2