bundler incorrectly trying to install "development" and "test" group gems in production
After a lot of digging I found the fix for this issue. All I had to do was run bundle install --without development test
before starting the server. This adds a .bundle/config
file in the rails root with the line BUNDLE_WITHOUT: test:development
. Now whenever you run bundle install
or start the server it'll ignore those groups.
From the documentation
The Bundler CLI allows you to specify a list of groups whose gems bundle install should not install with the --without option. To specify multiple groups to ignore, specify a list of groups separated by spaces.
bundle install --without test bundle install --without development test After running bundle install --without test, bundler will remember that you excluded the test group in the last installation. The next time you run bundle install, without any --without option, bundler will recall it.
Also, calling Bundler.setup with no parameters, or calling require "bundler/setup" will setup all groups except for the ones you excluded via --without (since they are obviously not available).
In my case it was installing gems from jenkins env. So i had to set my own bundle_without variable in capistrano.
Gemfile
group :test, :development, :jenkins do
gem 'test-unit', '1.2.3'
gem 'rspec-rails'
end
deploy.rb
set :bundle_without, [:development, :test, :jenkins]