2013-10-17 135 views
7

我試圖將我的rails應用程序部署到使用Capistrano 3.0的EC2實例中。我現在正在運行「cap production deploy」或「cap production bundler:install」時出現的以下輸出。Capistrano bundler:安裝失敗

DEBUG [5b379979] Running /usr/bin/env if test ! -d /var/www/app/current; then echo "Directory does not exist '/var/www/app/current'" 1>&2; false; fi on ec2-75-101-200-185.compute-1.amazonaws.com 
DEBUG [5b379979] Command: if test ! -d /var/www/app/current; then echo "Directory does not exist '/var/www/app/current'" 1>&2; false; fi 
DEBUG [5b379979] Finished in 2.285 seconds command successful. 
INFO [f15c9f08] Running /usr/bin/env bundle --gemfile /var/www/app/current/Gemfile --path /var/www/app/shared/bundle --deployment --verbose --binstubs /var/www/billtune/shared/bin --without development test on ec2-75-101-200-185.compute-1.amazonaws.com 
DEBUG [f15c9f08] Command: cd /var/www/app/current && /usr/bin/env bundle --gemfile /var/www/app/current/Gemfile --path /var/www/app/shared/bundle --deployment --verbose --binstubs /var/www/app/shared/bin --without development test 
DEBUG [f15c9f08] /usr/bin/env: 
DEBUG [f15c9f08] bundle 
DEBUG [f15c9f08] : No such file or directory 
DEBUG [f15c9f08]  
cap aborted! 
bundle stdout: Nothing written 
bundle stderr: Nothing written 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/command.rb:94:in `exit_status=' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:125:in `block (4 levels) in _execute' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:147:in `block (2 levels) in _execute' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:149:in `block in _execute' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `tap' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `_execute' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:54:in `execute' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-bundler-1.0.0/lib/capistrano/tasks/bundler.cap:20:in `block (4 levels) in <top (required)>' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/backends/abstract.rb:81:in `within' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/capistrano-bundler-1.0.0/lib/capistrano/tasks/bundler.cap:19:in `block (3 levels) in <top (required)>' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `run' 
/Users/shaimo-mbp/.rvm/gems/ruby-1.9.3-p448/gems/sshkit-1.0.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' 
Tasks: TOP => bundler:install 

當SSH-ING到服務器並運行相同的命令(「CD /無功/網絡/應用/電流& &的/ usr/bin中/ env的束--gemfile /無功/網絡/應用/電流/ Gemfile --path/var/www/app/shared/bundle --deployment --verbose --binstubs/var/www/app/shared/bin --without development test「)似乎都沒問題...

對此非常絕望...... 謝謝!

回答

4

線條

DEBUG [f15c9f08] Command: cd /var/www/app/current && /usr/bin/env bundle --gemfile /var/www/app/current/Gemfile --path /var/www/app/shared/bundle --deployment --verbose --binstubs /var/www/app/shared/bin --without development test 
DEBUG [f15c9f08] /usr/bin/env: 
DEBUG [f15c9f08] bundle 
DEBUG [f15c9f08] : No such file or directory 
DEBUG [f15c9f08]  

指示捆綁沒有找到,或者未安裝。 Capistrano(在此記錄爲http://www.capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/)運行在非登錄非交互式外殼中。

我猜測bundler安裝在特殊路徑中,或者您正在使用rvm,chr​​uby或rbenv。而且,由於Capistrano正在使用的非登錄非交互式會話,因此這些內容不會像初始化時那樣進行初始化。

解決方案是使用capistrano-{rvm,chruby,rbenv}適合您的環境的寶石,如Capfile中所述。

如果不使用這些版本的經理之一,試試這個:

ssh [email protected] 'which bundler' 

也許你會看不到輸出(更多關於爲什麼在上面的鏈接),解決這個問題,並Capistrano的將工作。

0

bundlebundle可執行文件從系統中丟失或其PATH未知的shell。

檢查下面的測試:

系統可以找到perl可執行:

# /usr/bin/env perl 
^C << I did CTRL+C as perl was expecitng me to put some code 

現在,我的系統無法找到perlyo可執行文件,並引發錯誤:

# /usr/bin/env perlyo 
/usr/bin/env: perlyo: No such file or directory 

上面的錯誤是類似於你得到的/usr/bin/env bundle這是:

DEBUG [f15c9f08] /usr/bin/env: 
DEBUG [f15c9f08] bundle 
DEBUG [f15c9f08] : No such file or directory 

檢查系統是否知悉以下命令運行約bundle

# which bundle 
# whereis bundle 

如果它不能與上面的命令找到,然後檢查是否bundle在所有存在於系統,如下:

# updatedb 
# locate bundle 

如果您找到bundle,請相應地添加它的path,以便您的shell可以識別它。

希望這會有所幫助。

2

這個問題確實與非交互式shell有關。

最後我不得不把下面一行添加到.bashrc

source ~/.rvm/scripts/rvm 

萬一別人得到類似的問題,我會補充一點,我也不得不映射rake命令所以它會正常工作。注意下列行添加到我的deploy.rb文件:

SSHKit.config.command_map[:rake] = "bundle exec rake" 
1

你最好使用Capistrano的-rbenv寶石來管理你的ROR ENV

  1. 添加gem 'capistrano-rbenv', '~> 2.0' to your的Gemfile
  2. 取消註釋require 'capistrano/rbenv'在capfile;如果capistrano/bundler評論,取消它也
  3. 設置rbenv_ruby變量set :rbenv_ruby, '2.0.0-p247'在部署文件

那麼所有的設置!

0

我能夠通過添加以下代碼在〜/ .bashrc來解決這個問題:

export RBENV_ROOT="${HOME}/.rbenv" 

if [ -d "${RBENV_ROOT}" ]; then 
    export PATH="${RBENV_ROOT}/bin:${PATH}" 
    eval "$(rbenv init -)" 
fi 
1

我有點晚來回答這個問題,但它可能會幫助一些用戶喜歡我。

如果您使用rbenv然後通過添加以下行deploy.rb

set :default_env, { path: "~/.rbenv/shims:~/.rbenv/bin:$PATH" }

0

設置你的rbenv的默認環境作爲@zpieslak說:

在〜/ .bashrc添加此

if [ -d "${RBENV_ROOT}" ]; then 
    export PATH="${RBENV_ROOT}/bin:${PATH}" 
    eval "$(rbenv init -)" 
fi 

在此行之前:

# If not running interactively, don't do anything 
case $- in 
    *i*) ;; 
     *) return;; 
esac