How do I set the shell to bash for run in Capistrano?

Charles picture Charles · Oct 13, 2011 · Viewed 10k times · Source

How can I set the shell in the Capistrano run command to use bash instead of sh? I am trying to install RVM and I need to execute the command:

run "bash < <(curl -L http://bit.ly/rvm-install-system-wide)"

as in:

task :install_rvm, :roles => :server do
  apps = %w(bison openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev     libyaml-dev sqlite3 libsqlite3-0 libxml2-dev libxslt-dev autoconf subversion libcurl4-openssl-dev)
  apt.install( {:base => apps}, :stable )
  run "bash < <(curl -L http://bit.ly/rvm-install-system-wide)"
  run "rvm install 1.9.2".sh
  run "rvm use 1.9.2@global"
  run "gem install awesome_print map_by_method wirble bundler builder pg cheat"
  run "gem install -v2.1.2 builder"
  # modify .bashrc
end

But I just can't seem to get it to work because Capistrano is executing:

"sh -c 'bash < <(curl -L http://bit.ly/rvm-install-system-wide)'" on ubuntu@ec2...

I see in the Capistrano gem the command.rb file has some code like

shell = "#{options[:shell] || "sh"} -c"

but it is unclear to me how to pass options[:shell] to the task

Answer

hipertracker picture hipertracker · Nov 25, 2011

set :shell is not working, but that works:

default_run_options[:shell] = '/bin/bash'