From Siberia with love

Migration from rvm to rbenv

After catching another rvm problem I decided to try new rbenv tool which aimed to be simpler unix-way rvm replacement. Moreover, after such drama, it really worth to try. So, the first thing I did was:

$ rvm implode
$ sudo rm /etc/rvmrc
$ rm ~/.rvmrc

Then I removed rm load hook from ~/.bash_profile.

You can install rbenv and ruby-build from homebrew if you are using Mac OS X, manually or any other method you like. I installed them manually due to some problems with homebrew installation. For some reason, ruby-build tried to install all rubies to ~/.rbenv, but rbenv installation was in /usr/local/Cellar, where all homebrew packages installing by default. So after you got them, you can install ruby version you need easily with new

$ rbenv install

command (supported from 20110914 version).

With rvm I used per-project gemset configuration, so in each project installed on my machine, I deleted .rvmrc and created .rbenv-version with the needed Ruby version in it.

.rbenv-version

1.9.2-p290

I didn't install rbenv-gemset plugin, because of managing project dependencies through gemsets and bundler together looks a little messy.

If typing bundle exec before each command makes you sad, you can try bundler-exec.

Custom ruby installation

I didn't find an easy method to install patched or implementation that not listed in ruby-build --definitions. In such situation you need to patch and/or compile it manually and move it to ${RBENV_ROOT}/versions.

JRuby workaround

If you are getting such errors you need to install

gem install jruby-launcher

and for 1.9 mode if needed

export JRUBY_OPTS=--1.9
gem install rake sources jruby-launcher

Conclusion

I find that rbenv+ruby-build is ready to use solution for managing multiple ruby versions. Besides advantages written on rbenv page managing dependencies exclusively through bundler exclude equal gem duplication installed in each gemset.