本文介绍了在 capistrano 3 + sshkit + rvm 中默认使用 bash --login的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下 cap3 任务
I have following cap3 task
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
它应该按照命令在我的服务器上执行
it should execute on my server following command
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 中,我有以下设置
In capistrano 2 for this I had following setting
default_run_options[:shell] = "/bin/bash --login"
但在 cap3 中它不起作用
But in cap3 it doesn't work
我尝试使用
set :pty, true
set :shell, '/bin/bash --login'
set :default_shell, '/bin/bash --login'
但是在 cap3 中它也不起作用
But in cap3 it doesn't work too
如何在没有 SSHkit.config 钩子的情况下解决 cap3 中的 bash --login 问题?
How can I solve bash --login problem in cap3 without SSHkit.config hook?
推荐答案
您不能从脚本中使用 rvm use
- 除非您像使用 prefix
,
you can not use rvm use
from scripts - unless you source rvm first like you did with the prefix
,
但是你可以在脚本中使用 rvm ... do ...
而无需采购:
but you can use rvm ... do ...
in scripts without sourcing:
execute :rvm, "#{ Configs.rvm.ruby }@#{ Configs.rvm.gemset }", "--create", :do, :true
这篇关于在 capistrano 3 + sshkit + rvm 中默认使用 bash --login的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!