1

我有一个在 Phusion Passenger 上运行的 Rails 应用程序,Apache 正在生产中。当我过去手动部署时一切正常(通过 SSH 连接到服务器并获取最新更新等),但我最近切换到 Capistrano 以使我的团队成员的生活更轻松。现在,当我尝试访问该站点时,Passenger 会抛出以下错误:Exception PhusionPassenger::UnknownError in PhusionPassenger::Rack::ApplicationSpawner (There was an error in your Gemfile, and Bundler cannot continue. (Bundler::GemfileError))

如果我运行 rails consolebundle exec rails console production并运行app.get('/'),它会返回状态码 200。所以这个 GemfileError 只有在请求通过Passenger时才会被抛出。

我一直为我拥有的每个 Rails 应用程序使用带有 gemsets 的 rvm,但 Capistrano 现在将包安装在/var/www/mywebsite/shared/bundle.

在我看来,rvm 和 capistrano 在处理 gem 的方式上存在冲突,但这并不能解释为什么它只会在这种环境下给出 GemfileError。

乘客错误

错误信息:

There was an error in your Gemfile, and Bundler cannot continue. (Bundler::GemfileError)

异常类:

PhusionPassenger::UnknownError

应用程序根:

/var/www/3eadmin/current

回溯

#   File    Line    Location
0   /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/dsl.rb   12  in `rescue in evaluate'
1   /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/dsl.rb   6   in `evaluate'
2   /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/definition.rb    18  in `build'
3   /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler.rb   144 in `definition'
4   /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler.rb   112 in `setup'
5   /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/setup.rb 17  in `'
6   /home/hatd/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb  60  in `require'
7   /home/hatd/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb  60  in `rescue in require'
8   /home/hatd/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb  35  in `require'
9   /var/www/3eadmin/releases/20121207090404/config/setup_load_paths.rb 17  in `'
10  /home/hatd/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb  36  in `require'
11  /home/hatd/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb  36  in `require'
12  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/utils.rb    301 in `prepare_app_process'
13  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/rack/application_spawner.rb 156 in `block in initialize_server'
14  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/utils.rb    563 in `report_app_init_status'
15  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/rack/application_spawner.rb 154 in `initialize_server'
16  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server.rb  204 in `start_synchronously'
17  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server.rb  180 in `start'
18  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/rack/application_spawner.rb 129 in `start'
19  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/spawn_manager.rb    253 in `block (2 levels) in spawn_rack_application'
20  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server_collection.rb   132 in `lookup_or_add'
21  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/spawn_manager.rb    246 in `block in spawn_rack_application'
22  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server_collection.rb   82  in `block in synchronize'
23      prelude>    10:in `synchronize'
24  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server_collection.rb   79  in `synchronize'
25  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/spawn_manager.rb    244 in `spawn_rack_application'
26  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/spawn_manager.rb    137 in `spawn_application'
27  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/spawn_manager.rb    275 in `handle_spawn_application'
28  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server.rb  357 in `server_main_loop'
29  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/lib/phusion_passenger/abstract_server.rb  206 in `start_synchronously'
30  /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/helper-scripts/passenger-spawn-server

软件版本

  • ruby -v: ruby​​ 1.9.3p327 (2012-11-10 修订版 37606) [i686-linux]
  • rvm -v: rvm 1.17.2 (stable) by Wayne E. Seguin, Michal Papis [https://rvm.io/]
  • bundle -v:捆绑器版本 1.2.3
  • capistrano: 2.13.5

软件位置

  • which ruby:/home/hatd/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
  • which rvm:/home/hatd/.rvm/bin/rvm
  • which bundle:/home/hatd/.rvm/gems/ruby-1.9.3-p327@global/bin/bundle

rvm 信息输出

ruby-1.9.3-p327:

  system:
    uname:       "Linux hatd 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 i686 i386 GNU/Linux"
    system:      "ubuntu/12.04/i386"
    bash:        "/bin/bash => GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.17.2 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "1 day 18 hours 3 minutes 27 seconds ago"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.3p327"
    date:         "2012-11-10"
    platform:     "i686-linux"
    patchlevel:   "2012-11-10 revision 37606"
    full_version: "ruby 1.9.3p327 (2012-11-10 revision 37606) [i686-linux]"

  homes:
    gem:          "/home/hatd/.rvm/gems/ruby-1.9.3-p327"
    ruby:         "/home/hatd/.rvm/rubies/ruby-1.9.3-p327"

  binaries:
    ruby:         "/home/hatd/.rvm/rubies/ruby-1.9.3-p327/bin/ruby"
    irb:          "/home/hatd/.rvm/rubies/ruby-1.9.3-p327/bin/irb"
    gem:          "/home/hatd/.rvm/rubies/ruby-1.9.3-p327/bin/gem"
    rake:         "/home/hatd/.rvm/gems/ruby-1.9.3-p327@global/bin/rake"

  environment:
    PATH:         "/home/hatd/.rvm/gems/ruby-1.9.3-p327/bin:/home/hatd/.rvm/gems/ruby-1.9.3-p327@global/bin:/home/hatd/.rvm/rubies/ruby-1.9.3-p327/bin:/home/hatd/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
    GEM_HOME:     "/home/hatd/.rvm/gems/ruby-1.9.3-p327"
    GEM_PATH:     "/home/hatd/.rvm/gems/ruby-1.9.3-p327:/home/hatd/.rvm/gems/ruby-1.9.3-p327@global"
    MY_RUBY_HOME: "/home/hatd/.rvm/rubies/ruby-1.9.3-p327"
    IRBRC:        "/home/hatd/.rvm/rubies/ruby-1.9.3-p327/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

Capistrano config/deploy.rb 包含

require 'bundler/capistrano'

.bundle/config 内容

---
BUNDLE_FROZEN: '1'
BUNDLE_PATH: /var/www/3eadmin/shared/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
BUNDLE_WITHOUT: development:test

宝石文件内容:

source 'https://rubygems.org'

gem 'rails', '3.1.3'

gem 'community_engine' , '2.0.0.beta4', :path => 'vendor/gems/community_engine-2.0.0.beta4'
gem 'pg'
gem 'json'
gem 'jquery-rails'
gem 'authority', '~> 2.0.0'
gem 'friendly_id', '~> 3.3'
gem 'hpricot'
gem 'aws-sdk', '~> 1.3.4'
gem 'bootstrap-sass', '~> 2.1.0.1'
gem 'coffee-rails', '~> 3.1.1'
gem 'rack-cors', :require => 'rack/cors'
gem 'event-calendar', :require => 'event_calendar'
gem 'apns'

group :development do 
  gem 'sqlite3'
  gem 'rspec-rails', "~> 2.9.0"
  gem 'capistrano'
  gem 'rvm-capistrano'
  gem 'guard-rspec', "~> 0.7.0"
end

group :assets do
  gem 'sass-rails', '~> 3.1.4'
  gem 'uglifier', '>= 1.0.3'
end

group :test do
  gem 'rspec-rails', "~> 2.9.0"
  gem 'capybara', '~> 1.1.2'
  gem 'factory_girl_rails', '~> 3.2.0'
end

宝石列表输出

*** LOCAL GEMS ***

bundler (1.2.3)
daemon_controller (1.1.0)
fastthread (1.0.7)
passenger (3.0.18)
rack (1.4.1)
rake (10.0.2)
rubygems-bundler (1.1.0)
rvm (1.11.3.5)

捆绑列表输出

gems included by the bundle:
  * XMLCanonicalizer (1.0.1)
  * actionmailer (3.1.3)
  * actionpack (3.1.3)
  * activemodel (3.1.3)
  * activerecord (3.1.3)
  * activeresource (3.1.3)
  * activesupport (3.1.3)
  * acts_as_commentable (3.0.1)
  * addressable (2.2.8)
  * apns (0.9.0)
  * arel (2.2.3)
  * authlogic (3.1.3)
  * authority (2.0.0)
  * aws-sdk (1.3.9)
  * babosa (0.3.7)
  * bborn-acts-as-taggable-on (2.2.1)
  * bootstrap-sass (2.1.0.1)
  * builder (3.0.0)
  * bundler (1.2.3)
  * cocaine (0.3.0)
  * coffee-rails (3.1.1)
  * coffee-script (2.2.0)
  * coffee-script-source (1.3.1)
  * community_engine (2.0.0.beta4)
  * configatron (2.9.1)
  * dynamic_form (1.1.4)
  * erubis (2.7.0)
  * event-calendar (2.3.3)
  * execjs (1.3.2)
  * faraday (0.7.6)
  * friendly_id (3.3.3.0)
  * haml (3.1.7)
  * hike (1.2.1)
  * hpricot (0.8.6)
  * htmlentities (4.3.1)
  * httparty (0.8.3)
  * i18n (0.6.0)
  * jquery-rails (1.0.19)
  * json (1.7.1)
  * kaminari (0.14.0)
  * koala (1.4.0)
  * log4r (1.1.10)
  * macaddr (1.6.1)
  * mail (2.3.3)
  * meta_search (1.1.3)
  * mime-types (1.18)
  * multi_json (1.0.4)
  * multi_xml (0.4.4)
  * multipart-post (1.1.5)
  * net-ldap (0.2.2)
  * nokogiri (1.5.2)
  * oa-basic (0.3.2)
  * oa-core (0.3.2)
  * oa-enterprise (0.3.2)
  * oa-more (0.3.2)
  * oa-oauth (0.3.2)
  * oa-openid (0.3.2)
  * oauth (0.4.6)
  * oauth2 (0.5.2)
  * omniauth (0.3.2)
  * paperclip (2.7.0)
  * pg (0.13.2)
  * polyamorous (0.5.0)
  * polyglot (0.3.3)
  * prototype-rails (3.1.0)
  * pyu-ruby-sasl (0.0.3.3)
  * rack (1.3.6)
  * rack-cache (1.2)
  * rack-cors (0.2.7)
  * rack-mount (0.8.3)
  * rack-openid (1.3.1)
  * rack-ssl (1.3.2)
  * rack-test (0.6.1)
  * rails (3.1.3)
  * rails_autolink (1.0.9)
  * railties (3.1.3)
  * rake (0.9.2.2)
  * rakismet (1.3.0)
  * rdoc (3.12)
  * recaptcha (0.3.4)
  * rest-client (1.6.7)
  * ri_cal (0.8.8)
  * ruby-openid (2.2.0)
  * ruby-openid-apps-discovery (1.2.0)
  * rubyntlm (0.1.1)
  * sanitize (2.0.3)
  * sass (3.1.17)
  * sass-rails (3.1.4)
  * sprockets (2.0.4)
  * systemu (2.5.2)
  * thor (0.14.6)
  * tilt (1.3.3)
  * tinymce-rails (3.4.9)
  * treetop (1.4.10)
  * tzinfo (0.3.33)
  * uglifier (1.2.4)
  * uuid (2.3.5)
  * uuidtools (2.1.2)
  * yamler (0.1.0)

乘客设置

/etc/apache2/mods-available/passenger.load

LoadModule passenger_module /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18/ext/apache2/mod_passenger.so


/etc/apache2/mods-available/passenger.conf

PassengerRoot /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/gems/passenger-3.0.18
PassengerRuby /home/hatd/.rvm/wrappers/ruby-1.9.3-p327@global/ruby
4

1 回答 1

1

好的,我希望这个问题的答案可能更有启发性,但这里是:

生产服务器上安装的 Bundler 版本是 1.2.3。我的开发机器上的版本是 1.2.1。

修复?

gem uninstall bundler
gem install bundler -v 1.2.1

这种事情属于 Bundler 的问题页面,我将在此之后及时发布。

于 2012-12-07T11:24:55.617 回答