I have a rails app that runs on Phusion Passenger with Apache in production. Everything worked when I used to manually deploy (by SSH-ing in to the server and fetching the latest updates, etc.), but I recently switched to Capistrano to make life easier on my team members. Now, when I try to access the site, Passenger throws the following error: Exception PhusionPassenger::UnknownError in PhusionPassenger::Rack::ApplicationSpawner (There was an error in your Gemfile, and Bundler cannot continue. (Bundler::GemfileError))
If I run the rails console bundle exec rails console production
, and run app.get('/')
, it gives back status code 200. So this GemfileError only gets thrown when the request passes through Passenger.
I have always used rvm with gemsets for each rails app I have, but Capistrano now installs the bundle in /var/www/mywebsite/shared/bundle
.
Seems to me like rvm and capistrano are conflicting in the way they handle gems, but that doesn't explain why it would give a GemfileError only in this environment.
Passenger Error
Error message:
There was an error in your Gemfile, and Bundler cannot continue. (Bundler::GemfileError)
Exception class:
PhusionPassenger::UnknownError
Application root:
/var/www/3eadmin/current
Backtrace
# 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
software versions
ruby -v
: ruby 1.9.3p327 (2012-11-10 revision 37606) [i686-linux]rvm -v
: rvm 1.17.2 (stable) by Wayne E. Seguin , Michal Papis [https://rvm.io/]bundle -v
: Bundler version 1.2.3capistrano
: 2.13.5
software locations
which ruby
: /home/hatd/.rvm/rubies/ruby-1.9.3-p327/bin/rubywhich rvm
: /home/hatd/.rvm/bin/rvmwhich bundle
: /home/hatd/.rvm/gems/ruby-1.9.3-p327@global/bin/bundle
rvm info output
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 contains
require 'bundler/capistrano'
.bundle/config contents
---
BUNDLE_FROZEN: '1'
BUNDLE_PATH: /var/www/3eadmin/shared/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
BUNDLE_WITHOUT: development:test
Gemfile contents:
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
gem list output
*** 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)
bundle list output
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)
Passenger Settings
/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
Okay, I wish the answer to this could have been something more illuminating, but here goes:
The Bundler version installed on the production server was 1.2.3. The version on my dev machine was 1.2.1.
The fix?
This sort of thing belongs on Bundler's issues page, where I will duly post right after this.