乘客在生产环境中错过了开发宝石

时间:2011-06-01 12:13:38

标签: ruby-on-rails gem passenger bundler environment

我的生产服务器上有一个奇怪的行为:我通过Capistrano将我的Rails 3应用程序部署到生产服务器。 Capistrano脚本在部署结束时重新启动乘客。当我打开应用程序时,我看到一条乘客错误消息:

Could not find autotest-fsevent-0.2.4 in any of the sources
(Bundler::GemNotFound)

当然,我的生产环境中没有安装autotest-fsevent(甚至无法在Ubuntu上安装......)

环境在apache的虚拟主机中设置:

<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>

这是我的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

为什么乘客(或捆绑者)认为它需要所有宝石而不是生产环境中的宝石?

感谢您的帮助!

2 个答案:

答案 0 :(得分:4)

您使用的是capistrano配方吗?

确保它位于config/deploy.rb

require 'bundler/capistrano'

基本上它会调用带有--without development test选项的bundle,它只能安装生产gem。如果你只是做一个普通的bundle,它会安装尝试为所有环境安装宝石。

答案 1 :(得分:0)

您的RAILS_ENV环境变量可能未定义,或者无意中设置为development,这可能导致加载错误的宝石集。您可能希望深入了解deploy.rb脚本以确保设置了正确的环境。

你应该在deploy.rb

中有类似的内容
task :production do
  # ...

  set :rails_env, 'production'

  # ...
end

您应该能够通过执行以下操作验证是否已正确设置:

cap production shell
cap> echo $RAILS_ENV
** [out :: myserver] production