在我的生產服務器上,我不想包含gem rspec rails。但是,試圖啓動我的導軌的服務器時,我得到一個錯誤:在生產Rails應用程序中,即使指示bundler跳過開發組,也會收到Bundler :: GemNotFound錯誤
/home/deployer/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.2/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find rspec-rails-2.12.0 in any of the sources (Bundler::GemNotFound)
from /home/deployer/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.2/lib/bundler/spec_set.rb:85:in `map!'
from /home/deployer/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.2/lib/bundler/spec_set.rb:85:in `materialize'
from /home/deployer/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.2/lib/bundler/definition.rb:114:in `specs'
from /home/deployer/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.2/lib/bundler/definition.rb:159:in `specs_for'
from /home/deployer/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.2/lib/bundler/runtime.rb:13:in `setup'
from /home/deployer/.rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.2/lib/bundler.rb:127:in `setup'
from /var/www/myapp/releases/20130311164742/config/boot.rb:8:in `<top (required)>'
from /home/deployer/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/deployer/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/rails:5:in `<main>'
我的Gemfile看起來像:
source 'http://rubygems.org'
ruby "1.9.3"
gem 'rails', '3.2.11'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
end
gem 'haml', '3.1.7'
gem 'devise', '2.2.0'
gem 'koala', '1.6.0'
gem "mongoid", "~> 3.0.0"
gem "braintree", "~>2.22.0"
group :development, :test do
gem 'rspec-rails', '2.12.0'
end
在我的配置/的boot.rb文件,我告訴打捆只尋找默認或相關環境包括寶石:
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'bundler'
Bundler.setup(:default, ENV["RAILS_ENV"])
end
我驗證過RAILS_ENV環境變量設置爲生產,通過運行:
$ echo $RAILS_ENV
並獲得'生產'回來。
爲什麼它仍然在尋找那個寶石,即使我告訴它不設置它?
「rails s」的命令行輸出是否表示開發或生產? – mlibby 2013-03-11 17:35:15
它沒有說什麼。對你的問題,以boot.rb我補充說: 把ENV [「RAILS_ENV」] 和它打印生產 – 2013-03-11 17:48:47