rbenv snippets

How to migrate from rvm to rbenv

Tagged rvm, bundle, rbenv  Languages ruby

These instructions explain how to migrate from rvm to rbenv.

Uninstall & Install

Start by executing the following command:

rvm implode.


  1. Install rbenv

Follow installation instructions found here

  1. Install ruby-build

Follow instructions found here

  1. Install REE
ruby-build ree-1.8.7-2011.03 $HOME/.rbenv/versions/ree-1.8.7-2011.03

Need Ruby 1.9? Check which versions of Ruby rbenv supports with this command:

ruby-build --definitions
  1. Set global ruby

Edit ~/.rbenv/default and add:


RVM Gemsets

You don't really need RVM gemsets as Bundler can install everything under your application directory. All you have to do is create the file ~/.bundle/config and put the following in it:

   BUNDLE_PATH: vendor/bundle

This will tell bundler to install the gems in vendor/bundle instead of the global environment. Verify that the configuration is okay by executing the following command:

% bundle config
Settings are listed in order of priority. The top value will be used.

  Set for the current user (/Users/christian/.bundle/config): "vendor/bundle"

  Set for your local app (/Users/christian/Projects/xxx/.bundle/config): "1"

Create alias for 'bundle exec'

With RVM out of the picture you'll have to run commands with 'bundle exec'.

Add this to /.bash_profile\ or/.zsh/aliases:

alias b='bundle exec'

This will save you some typing by allowing:

b rails console # same as "bundle exec rails console"


* If you have issues compiling ree because of readline errors, make sure you have the latest version of ruby-build and then try specifying some options when compiling:

CONFIGURE_OPTS="-c --enable-shared -c --with-readline-dir=/usr/local/Cellar/readline/6.2.1/" ruby-build ree-1.8.7-2011.03 ~/.rbenv/versions/ree-1.8.7-2011.03

* System wide installation can be achieved as outlined in this gist.

Running (and debugging) cronjobs with rbenv and bundler

Tagged backup, rbenv, cron, bundler  Languages bash

This snippet shows how to run a backup script (Backup gem) and how to debug cron in case it doesn't work.

This example uses bundler and rbenv to complicate things:

# Set the path to include rbenv

# Debug cron environment...
*/1 * * * * /bin/bash -l -c '/bin/env > /tmp/cron-env.log'

# Run backup every 12 hours
* */12 * * * /bin/bash -l -c 'eval "$(rbenv init -)" && cd /var/www/xxx/current && bundle exec backup perform --trigger xxx -c config/backup.rb >> /tmp/backup.log 2>&1'

If backup fails, check /tmp/backup.log and/or /tmp/cron-env.log.