简体   繁体   English

Capistrano bundler:安装失败

[英]Capistrano bundler:install fails

I'm trying to deploy my rails app into an EC2 instance using Capistrano 3.0. 我正在尝试使用Capistrano 3.0将我的rails应用程序部署到EC2实例中。 I'm now stack with the following output which appears when running "cap production deploy" or "cap production bundler:install". 我现在正在使用以下输出进行堆叠,该输出在运行“cap production deploy”或“cap production bundler:install”时出现。

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

When ssh-ing into the server and running the same 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") all seems to be ok... 当ssh进入服务器并运行相同的命令时(“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“)似乎一切都好......

Getting quite desperate about this... Thanks! 对此非常绝望......谢谢!

The lines 线条

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]    

Indicate that bundler isn't found, or isn't installed. 表示未找到或未安装bundler。 Capistrano (as documented here http://www.capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/ ) runs in a non-login, non-interactive shell . Capistrano(在此处记录http://www.capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/ )以非登录方式运行,非交互式shell

I would guess that bundler is installed in a special path, or that you are using rvm, chruby, or rbenv. 我猜想捆绑器安装在一个特殊的路径中,或者你正在使用rvm,chr​​uby或rbenv。 And that these things aren't being initialized as they are when you SSH into the box, because of the non-login, non-interactive session that Capistrano is using. 由于Capistrano正在使用的非登录,非交互式会话,因此当您通过SSH进入框时,这些内容未被初始化。

The solution is to use either the capistrano-{rvm,chruby,rbenv} gem which suits your envrironment as documented in the Capfile . 解决方案是使用适合您的环境的capistrano-{rvm,chruby,rbenv} gem,如Capfile中所述。

If you are not using one of those version managers, try this: 如果您没有使用其中一个版本管理器,请尝试以下操作:

ssh me@theserver 'which bundler'

Probably you will see no output (more on why at the link above), solve that, and Capistrano will work. 可能你会看到没有输出(更多关于为什么在上面的链接),解决它,并且Capistrano将工作。

The issue was indeed with the non-interactive shell . 问题确实在于非交互式shell

Eventually I had to add the following line to .bashrc : 最后我不得不.bashrc下行添加到.bashrc

source ~/.rvm/scripts/rvm

In case others get into similar issues, I will add that I also had to map the rake command so it would work properly. 如果其他人遇到类似的问题,我会补充一点,我还必须映射rake命令,以便它能正常工作。 Had to add the following line to my deploy.rb file: 必须deploy.rb添加到我的deploy.rb文件中:

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

You'd better use capistrano-rbenv gem to manage your ror env 你最好使用capistrano-rbenv gem来管理你的ror env

  1. add gem 'capistrano-rbenv', '~> 2.0' to your gemfile gem 'capistrano-rbenv', '~> 2.0' to your gemfile中
  2. uncomment require 'capistrano/rbenv' in your capfile; 取消注释require 'capistrano/rbenv'在capfile中使用require 'capistrano/rbenv' ; if capistrano/bundler commented, uncomment it also 如果capistrano/bundler评论,也取消注释
  3. set the rbenv_ruby variable set :rbenv_ruby, '2.0.0-p247' in your deploy file 在部署文件中设置rbenv_ruby变量set :rbenv_ruby, '2.0.0-p247'

then all set! 一切都准备好了!

I'm bit late to answer the question, but it might help some user like me. 我回答这个问题有点迟了,但它可能对像我这样的用户有所帮助。

If you're using rbenv then set the default environment of your rbenv by adding below line in deploy.rb 如果您使用rbenv然后设定的默认环境rbenv通过添加下面一行deploy.rb

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

The bundle executable is missing from system or its PATH is not known to the shell. 系统中缺少bundle可执行文件,或者shell不知道其PATH。

Check below test: 检查以下测试:

system can find perl executable: 系统可以找到perl可执行文件:

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

now, my system can't find perlyo executable and throws the error: 现在,我的系统找不到perlyo可执行文件并抛出错误:

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

Above error is similar to what you get for /usr/bin/env bundle which is: 以上错误类似于您获得的/usr/bin/env bundle ,它是:

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

check whether system knows about bundle by running below command: 通过运行以下命令检查系统是否知道bundle

# which bundle
# whereis bundle

If it can't find with above commands, then check whether bundle at all exists on system as below: 如果找不到上面的命令,那么检查系统上是否存在bundle ,如下所示:

# updatedb
# locate bundle

If you find the bundle , then add its path accordingly so that your shell can recognize it. 如果找到bundle ,则相应地添加其path ,以便shell可以识别它。

Hope this helps. 希望这可以帮助。

I was able to solve the issue by adding the following code to ~/.bashrc: 我能够通过将以下代码添加到〜/ .bashrc来解决问题:

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

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

As @zpieslak said: 正如@zpieslak所说:

add this in ~/.bashrc: 在〜/ .bashrc中添加:

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

Before this line: 在此之前:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM