![Capistrano Shell 环境错误](https://linux22.com/image/615422/Capistrano%20Shell%20%E7%8E%AF%E5%A2%83%E9%94%99%E8%AF%AF.png)
我正在尝试让 capistrano 与 rvm 和 Passenger 独立版一起工作。我曾经让它工作过,然后 capistrano 突然开始抱怨缺少 bundle 命令。当我删除时require 'bundler/capistrano'
,它不再抱怨缺少 bundle(并且不再尝试捆绑),但会失败并显示以下内容:
...
* 2013-07-25 14:29:16 executing `deploy:restart'
* executing "if [[ -f /home/staging/capistrano/shared/tmp/pids/passenger.80.pid ]];\\\n then\\\n cd /home/staging/capistrano/current && rvmsudo passenger stop -p 80;\\\n fi"
servers: ["ccdev.dyndns.org"]
[ccdev.dyndns.org] executing command
** [out :: ccdev.dyndns.org] sh: 1:
** [out :: ccdev.dyndns.org] [[: not found
** [out :: ccdev.dyndns.org]
command finished in 13ms
* executing "cd /home/staging/capistrano/current && rvmsudo passenger start -e staging -p 80 -d"
servers: ["ccdev.dyndns.org"]
[ccdev.dyndns.org] executing command
** [out :: ccdev.dyndns.org] sh: 1:
** [out :: ccdev.dyndns.org] rvmsudo: not found
** [out :: ccdev.dyndns.org]
command finished in 13ms
failed: "env rvmsudo_secure_path=1 sh -c 'cd /home/staging/capistrano/current && rvmsudo passenger start -e staging -p 80 -d'" on ccdev.dyndns.org
显然,我的部署用户的 shell 环境中缺少一些路径变量,但仅当从 capistrano 调用时才会出现这种情况。所有相关命令都手动运行。我不确定从哪里开始查找。这是staging.rb 顶部env rvmsudo_secure_path=1
的结果default_run_options[:env] = {'rvmsudo_secure_path' => 1}
,它阻止显示 rvm 错误并挂起部署过程。部署工作之前它就存在。
答案1
bundler/capistrano
默认设置并不总是最好的选择,这就是为什么建议rvm-capistrano
将这些设置重置为使用标准 ruby 路径(system
在捆绑器中调用 - 但与系统本身无关)
我维护示例应用程序https://github.com/mpapis/ad/blob/master/config/deploy.rb对你来说最少的摘录是:
require "rvm/capistrano"
require "bundler/capistrano"
set :bundle_dir, ''
set :bundle_flags, '--system --quiet'
set :bundle_without, [:development]