Phusion-Passenger

Capistrano Shell 環境錯誤

  • July 30, 2013

我正在嘗試讓 capistrano 與 rvm 和乘客獨立工作。我曾經讓它工作過,然後 capistrano 突然開始抱怨缺少 bundle 命令。當我刪除require 'bundler/capistrano'時,它不再抱怨缺少捆綁包(並且不再嘗試捆綁)但失敗並顯示以下內容:

...
* 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 呼叫時才會如此。所有有問題的命令都是手動工作的。我不確定從哪裡開始尋找。這env rvmsudo_secure_path=1default_run_options[:env] = {'rvmsudo_secure_path' => 1}staging.rb 頂部的結果,它阻止了 rvm 錯誤顯示和掛起部署過程。它在部署工作之前就存在。

bundler/capistrano預設設置並不總是最佳選擇,這就是為什麼建議rvm-capistrano將這些設置重置為使用標準 ruby​​ 路徑system在 bundler 中呼叫 - 但與系統本身無關)

我維護範例應用程序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]

引用自:https://serverfault.com/questions/526316