1

I am using capistrano to deploy a rails application to production. Everything appears to work and capistrano does not report any errors however the application fails to start with the following error message

Ruby (Rack) application could not be started 
Could not find activemodel-3.2.0 in any of the sources (Bundler::GemNotFound)

When examining the bundled gems the correct version of gems are in the shared folder but passenger does not appear to be using them. Summarised output from cap deploy is as follows

  * executing "cd /opt/geonovo/retail/releases/20120628125205 && \
    bundle install --gemfile /opt/geonovo/retail/releases/20120628125205/Gemfile \
    --path /opt/geonovo/retail/shared/bundle --deployment \
    --without development test"
    servers: ["rt-devrails01"]
    [rt-devrails01] executing command
 ** [out :: rt-devrails01] Fetching source index for http://rubygems.org/
 ** [out :: rt-devrails01] Using activesupport (3.2.0)
 ** [out :: rt-devrails01] 
 ** [out :: rt-devrails01] Using builder (3.0.0)
 ** [out :: rt-devrails01] 
 ** [out :: rt-devrails01] Installing activemodel (3.2.0)
 ...
 ...
 * [out :: rt-devrails01] 
 ** [out :: rt-devrails01] Your bundle is complete! 
 It was installed into /opt/geonovo/retail/shared/bundle
 command finished in 47529ms

running gem list on the production server does not show the activemodel 3.2.0 gem being present but the shared directory /opt/geonovo/retail/shared/bundle/ruby/1.9.1/gems/ does include an entry for activemodel-3.2.0.

The production servers /bundle/config file contains the following

--- 
BUNDLE_FROZEN: "1"
BUNDLE_PATH: /opt/geonovo/retail/shared/bundle
BUNDLE_DISABLE_SHARED_GEMS: "1"
BUNDLE_WITHOUT: development:test

Running bundle check on the production server shows the following

The following gems are missing
 * activemodel (3.2.0)
 * actionpack (3.2.0)
 * actionmailer (3.2.0)
 * activerecord (3.2.0)
 * activeresource (3.2.0)
 * railties (3.2.0)
 * rails (3.2.0)
Install missing gems with `bundle install`

I could probably install the gems using bundle install but I want the deploy to happen within capistrano if possible.

The beginning of the Gemfile includes the following lines

source 'http://rubygems.org'

gem 'rails', '>= 3.2.0'

Steve Weet
  • 28,126
  • 11
  • 70
  • 86

1 Answers1

0

It seems that the issue was that my gem version was out of date. Bundler was working OK but the application was failing to start due to problems loading gems.

The problem became obvious when checking /var/log/httpd/error_log which revealed many errors like the following :-

WARNING:  #<ArgumentError: Illformed requirement 
  ["<Syck::DefaultKey:0x00000016a73648> 3.2.0"]>
WARNING:  Invalid .gemspec format in '...bundle/ruby/1.9.1/specifications/rails-3.2.0.gemspec'

This led me to the following question and the solution which is to update gem to a current version, using sudo gem update --system and then restart apache. (Restarting passenger did not seem to be enough.

Community
  • 1
  • 1
Steve Weet
  • 28,126
  • 11
  • 70
  • 86