我正在尝试使用Capistrano 3.0将我的rails应用程序部署到EC2示例中。现在,我将堆栈以下输出,这些输出在运行“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
当ssh-ing进入服务器并运行相同的命令(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
)时,一切似乎都正常。
7条答案
按热度按时间db2dz4w81#
台词
指示未找到或未安装bundler。Capistrano(如本文http://www.capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/所述)在非登录、非交互式shell中运行。
我猜bundler安装在一个特殊的路径中,或者您使用的是rvm、chruby或rbenv,并且这些东西没有像您SSH到机器中时那样初始化,因为Capistrano使用的是非登录、非交互式会话。
解决方案是使用
capistrano-{rvm,chruby,rbenv}
gem,它适合您的环境,如Capfile
中所述。如果您没有使用这些版本管理器之一,请尝试以下操作:
也许你会看到没有输出(更多关于为什么在上面的链接),解决这个问题,卡皮斯特拉诺将工作。
eimct9ow2#
问题确实出在 * 非交互式shell* 上。
最后,我不得不在
.bashrc
中添加以下行:如果其他人遇到类似的问题,我将补充说,我还必须Map
rake
命令,以便它可以正常工作。必须添加以下行到我的deploy.rb
文件:hpcdzsge3#
你最好使用capistrano-rbenv gem来管理你的ror环境
1.添加
gem 'capistrano-rbenv', '~> 2.0' to your
宝石文件1.取消注解capfile中的
require 'capistrano/rbenv'
;如果capistrano/bundler
已注解,则也取消注解1.在部署文件中设置rbenv_ruby变量
set :rbenv_ruby, '2.0.0-p247'
那就都准备好了!
h5qlskok4#
我可以通过在~/.bashrc中添加以下代码来解决这个问题:
n3schb8v5#
我回答这个问题有点晚了,但它可能会帮助一些像我这样的用户。
如果您使用的是
rbenv
,则通过在deploy.rb
中的下面一行中添加以下内容来设置rbenv
的默认环境set :default_env, { path: "~/.rbenv/shims:~/.rbenv/bin:$PATH" }
kx7yvsdv6#
系统中缺少
bundle
可执行文件,或者shell不知道其路径。检查以下测试:
系统可以找到
perl
可执行文件:现在,我的系统找不到
perlyo
可执行文件,并抛出错误:以上错误与
/usr/bin/env bundle
的错误类似,即:通过运行以下命令检查系统是否知道
bundle
:如果使用上述命令无法找到,则检查系统上是否存在
bundle
,如下所示:如果找到
bundle
,则相应地添加它的path
,以便shell能够识别它。希望这个有用。
gc0ot86w7#
正如@zpieslak所说:
在~/.bashrc中添加以下内容:
此行之前: