Capistrano

Quentin Brossard edited this page Feb 6, 2014 · 7 revisions

chruby can be used with Capistrano to select a specific Ruby when deploying.

Capistrano 3

Support is provided out of the box when using Capistrano version 3.

Setup instructions are available here: https://github.com/capistrano/chruby

Capistrano 2

Capfile / deploy.rb

default_run_options[:shell] = '/bin/bash'
set :ruby_version, "1.9.3-p327"
set :chruby_config, "/usr/local/share/chruby/chruby.sh"
set :set_ruby_cmd, "source #{chruby_config} && chruby #{ruby_version}"
set(:bundle_cmd) {
  "#{set_ruby_cmd} && exec bundle"
}

Alternative

If chruby-exec is in your server's PATH (and if it's not, why isn't it?), the following solution will work, too:

set :ruby_version,  "2.0"
set :bundle_cmd,    "chruby-exec #{ruby_version} -- bundle"