2011-06-01 58 views
2

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

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

过程自动测试,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 

为什么乘客(或打包者)认为它需要所有的宝石,而不仅仅是生产环境的宝石?

感谢您的帮助!

+0

你可以发布你的Gemfile吗? – 2011-06-01 12:44:51

+0

已被加入到我的问题中 - 帖子... – 2011-06-01 14:18:58

回答

4

您使用的是捆绑Capistrano的食谱?

确保这是您的config/deploy.rb

require 'bundler/capistrano' 

基本上,它会调用束与--without development test选项,它应该只安装生产的宝石。如果你只是做一个正规的bundle,它会安装尝试安装所有环境的宝石。

+0

好的,我将它添加到了我的deploy.rb中。现在部署过程根本不起作用,我认为是因为我的Gemfile中的git引用的gem(geokit-rails3)。由于这个宝石现在也可用于rubygems,所以我删除了github-reference和TADA:我的部署过程再次运行。感谢你的帮助! :-) – 2011-06-08 13:46:06

0

您可能会将您的RAILS_ENV环境变量定义为undefined,或者无意中将其设置为development,这可能会导致加载错误的一组gem。您可能需要深入了解deploy.rb脚本以确保设置了正确的环境。

你应该有deploy.rb是这样的:

task :production do 
    # ... 

    set :rails_env, 'production' 

    # ... 
end 

您应该能够验证这是通过这样设置正确:

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