问题
I've got a strange behaviour on my production server: I deploy my Rails 3 application via Capistrano to the production server. The Capistrano script restarts passenger at the end of deployment. When I open the application I see a passenger error message:
Could not find autotest-fsevent-0.2.4 in any of the sources
(Bundler::GemNotFound)
Of course autotest-fsevent is not installed in my production environment (and even can't be installed on Ubuntu...)
The environment is set in apache's virtualhost:
<VirtualHost *>
PassengerMinInstances 1
ServerName test.myapp.de
DocumentRoot /var/www/myapp/current/public
RailsEnv production
RackEnv production
<Directory /var/www/myapp/current/public/>
Options -Indexes
AllowOverride None
Order deny,allow
Deny from none
Allow from all
AddOutputFilterbyType DEFLATE text/html
FileEtag none
</Directory>
LogLevel warn
ErrorLog /var/www/myapp/shared/log/error.log
CustomLog /var/www/myapp/shared/log/access.log combined
</VirtualHost>
Here is my Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.6'
gem 'jquery-rails'
gem 'mysql'
gem 'simple-navigation'
gem 'geokit'
gem 'geokit-rails3', :git => "git://github.com/loosecubes/geokit-rails3.git"
gem 'validates_timeliness', '~> 3.0.2'
gem 'delocalize'
gem 'prawn'
group :development do
gem 'rspec-rails', '2.5.0'
gem 'faker', '0.3.1'
#gem 'ruby-debug19'
gem 'ruby-debug'
gem 'autotest', '4.4.6'
gem 'autotest-rails-pure', '4.1.2'
gem 'autotest-fsevent', '0.2.4'
gem 'autotest-growl', '0.2.9'
end
group :test do
gem 'rspec', '2.5.0'
gem 'rcov'
gem 'webrat', '0.7.1'
gem 'factory_girl_rails', '1.0'
end
Why does passenger (or bundler) think it needs ALL gems instead only the gems for production environment?
Thanks for your help!
回答1:
Are you using the bundler capistrano recipes?
Make sure this is in your config/deploy.rb
require 'bundler/capistrano'
Basically it will invoke bundle with the --without development test
option, which should only install the production gems. If you are just doing a regular bundle
, it will install try to install the gems for all environments.
回答2:
You might have your RAILS_ENV
environment variable either undefined, or set inadvertently to development
which could cause the wrong set of gems to be loaded. You might want to dig in to your deploy.rb
script to ensure that the correct environment is set.
You should have something like this in deploy.rb
:
task :production do
# ...
set :rails_env, 'production'
# ...
end
You should be able to verify that this is set correctly by doing this:
cap production shell
cap> echo $RAILS_ENV
** [out :: myserver] production
来源:https://stackoverflow.com/questions/6200931/passenger-misses-development-gem-in-production-environment