在生产rails应用程序中,获取Bundler :: GemNotFound错误,即使指示bundler跳过开发组

时间:2013-03-11 17:14:53

标签: ruby-on-rails bundler

在我的生产服务器上,我不想包含gem rspec rails。但是,当尝试使用rails s启动我的服务器时,出现错误:

/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

在我的config / boot.rb文件中,我告诉bundler只查找默认包含的gem或相关环境:

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

让'生产'回归。

为什么它仍在寻找那颗宝石,即使我告诉它不要设置它?

1 个答案:

答案 0 :(得分:0)

这是一个错字吗? echo $RAILS_ENV。你错过了Rails中的's'。