私の運用サーバーでは、gem rspec レールを含めたくありません。ただし、サーバーを 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>'
私の宝石ファイルは次のようになります。
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 ファイルで、デフォルトで含まれる 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 環境変数が production に設定されていることを確認しました。
$ echo $RAILS_ENV
そして「生産」を取り戻します。
設定しないように指示したのに、まだその宝石を探しているのはなぜですか?