Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

During my deploy, I want to create a .rvmrc file in the /current folder during a capistrano deployment.

How can I do this?

share|improve this question
up vote 1 down vote accepted

You can add tasks to a Capistrano deploy using syntax shown below :

task :gitinstall do
   run "apt-get update"
   run "apt-get -y install git-core"
before "deploy:update", :gitinstall

This example has each machine install git before running the deploy. All you have to do is modify this to wget the file in question or do a bash echo.

share|improve this answer
thanks, but why 'bash echo', I need a command to create a file on the fly and add something like ruby-version@gemset_name no? – Blankman Dec 18 '10 at 17:04
If you need to add that in the file you can do : echo "ruby-version@gemset_name no" >> ~/.rvmrc – Antoine Benkemoun Dec 18 '10 at 22:24

I'll leave this here as reference. Should work with newer versions of rbenv or rvm.

namespace :deploy do
  desc 'Sets the ruby version'
  task :set_ruby_version do
    put "2.0.0-p0", "#{latest_release}/.ruby-version"

after 'deploy:update_code', 'deploy:set_ruby_version'

or, if you're using capistrano/bundler, you need this hook instead:

before 'bundle:install', 'deploy:set_ruby_version'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.