目前,我尝试使用 capistrano 部署我的 Rails 4 项目。目前,服务器与主机相同,但使用的用户不同。问题是 capistrano 不能同时正确加载 RVM 和局部变量。局部变量设置在/etc/profile.d/oracle.sh
set :default_shell, "bash -l"
set :rvm_ruby_string, "ruby-2.0.0-p0@rails4"
require "rvm/capistrano"
set :use_sudo: false
...
...
desc "tester"
task :tester, hosts: "localhost" do
run "echo $TNS_ADMIN"
run "ruby -v"
run "gem list"
end
如果我使用此设置,我会得到:
echo $TNS_ADMIN --> "correct path"
ruby -v --> 2.0.0p195 (wrong version)
gem list --> 5 gems (wrong)
如果我不使用set :default_shell, "bash -l"
,我会得到:
echo $TNS_ADMIN --> "" (wrong)
ruby -v --> 2.0.0p0 (correct version)
gem list --> > 100 gems (correct)
如果我使用set :default_shell, :bash
,我会得到:
echo $TNS_ADMIN --> "" (wrong)
ruby -v --> 1.9.3p194 (wrong version = ruby version of the system)
gem list --> > 5 gems (wrong)
如果我不使用set :rvm_ruby_string
,我会得到同样的错误结果,就像使用两行 (set :default_shell, "bash -l"
和set :rvm_ruby_string, "..."
)
但我想$TNS_ADMIN
设置局部变量和正确的 ruby/gemset(2.0.0p0@rails 有 > 100 个宝石)。我错过了什么?