Skip to content

Instantly share code, notes, and snippets.

@wmene
Created February 22, 2012 00:14
Show Gist options
  • Save wmene/1880099 to your computer and use it in GitHub Desktop.
Save wmene/1880099 to your computer and use it in GitHub Desktop.
Cap recipe to create an rvm gemset before deploy
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, "1.8.7@#{application}" # Or whatever env you want it to run in.
# Make sure the gemset exists before running deploy:setup
def disable_rvm_shell(&block)
old_shell = self[:default_shell]
self[:default_shell] = nil
yield
self[:default_shell] = old_shell
end
task :create_gemset do
disable_rvm_shell { run "rvm use #{rvm_ruby_string} --create" }
end
before "deploy:setup", "create_gemset"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment