我有以下CAP3任务
task :gemset do
on roles(:all) do
if remote_dir_exists?(".rvm")
execute :rvm, :gemset, :use, "#{ Configs.rvm.ruby }@#{ Configs.rvm.gemset } --create"
else
info "RVM not installed"
end
end
end
设置
rvm:
ruby: ruby-2.0.0-p247
gemset: cap3
它应该在我的服务器上执行命令
rvm gemset use ruby-2.0.0-p247@cap3 --create
,但它给了我
DEBUG [9bd5fc11] RVM is not a function, selecting rubies with 'rvm use ...' will not work.
DEBUG [9bd5fc11]
DEBUG [9bd5fc11] You need to change your terminal emulator preferences to allow login shell.
DEBUG [9bd5fc11] Sometimes it is required to use `/bin/bash --login` as the command.
DEBUG [9bd5fc11] Please visit https://rvm.io/integration/gnome-terminal/ for a example.
用
解决SSHKit.config.command_map.prefix[:rvm].push("source .bash_profile &&")
现在我的任务看起来像
task :gemset do
on roles(:all) do
if remote_dir_exists?(".rvm")
SSHKit.config.command_map.prefix[:rvm].push("source .bash_profile &&")
execute :rvm, :gemset, :use, "#{ Configs.rvm.ruby }@#{ Configs.rvm.gemset } --create"
else
info "RVM not installed"
end
end
end
在Capistrano 2中,我有以下设置
default_run_options[:shell] = "/bin/bash --login"
但是在CAP3中它不起作用
我尝试使用
set :pty, true
set :shell, '/bin/bash --login'
set :default_shell, '/bin/bash --login'
但是在CAP3中它不起作用
我如何解决 bash -login cap3中的问题,没有sshkit.config钩?
您无法从脚本中使用rvm use
- 除非您像prefix
一样先源RVM,
但是您可以在脚本中使用rvm ... do ...
而无需采购:
execute :rvm, "#{ Configs.rvm.ruby }@#{ Configs.rvm.gemset }", "--create", :do, :true