How can I set the shell in the Capistrano run command to use bash instead of sh? I am 开发者_如何学Pythontrying 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
set :shell is not working, but that works:
default_run_options[:shell] = '/bin/bash'
It sounds like you need the rvm-capistrano gem. Another option would be to use the mechanism used by rvm-capistrano, that is:
set :default_shell, '/bin/bash -l'
Try setting the :shell
variable.
set :shell, '/usr/bin/bash'
You can also use the following syntax:
execute "bash -c '<command>'"
It is especially useful for setting environment with --login switch, for example:
execute "bash --login -c 'rvm use 1.9.2'"
...and it also works in Capistrano 3.x...!
Be sure to wrap the command in single quotes so that it is passed to bash
as a single argument, and so that pathname expansion (globbing), parameter expansion and so on are not performed too early.
精彩评论