在我的生产服务器上,我不想包含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
在我的配置/启动。我告诉打包器只查找默认包含的gem或相关环境的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
让"生产"回归。
为什么我告诉它不要设置,它还在寻找那颗宝石?
是不是打错了?echo $RAILS_ENV
。你漏掉了Rails中的's'