Rails bundler doesn't install gems inside a group

Ruby on-RailsRubyRubygemsBundler

Ruby on-Rails Problem Overview


I have several gems including ruby-debug in a bundler group called :development. When I run the bundle command, these gems are ignored and it only installs the gems that are not in any group. How can I make sure bundler doesn't ignore the gems in the :development group?

Edit: This is what my Gemfile looks like.

source 'http://rubygems.org'
gem 'rails', '3.0.1'

# Auth gems
gem "devise", "1.1.3"
gem "omniauth"

# Bundle Mongoid gems
gem "mongoid", "2.0.0.beta.19"
gem "bson_ext"

# Asset gems
gem 'jquery-rails'
gem "jammit"

# Controller gems
gem 'inherited_resources', '1.1.2'

# View gems
gem 'haml'
gem 'formtastic', '~> 1.1.0'

# Nokogiri
gem "mechanize"
gem "json"


group :development do
  gem "ruby-debug"
  gem 'compass'
  gem 'compass-colors'
  gem 'pickler'
  gem 'haml-rails'
  gem 'rails3-generators'
  gem "hpricot"
  gem "ruby_parser"
  gem 'fog'
end

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

Within a term session, it remembers the without option. If you first ran

bundle install --without development 

it remembers that you did this and will automatically repeat this for the next

bundle install #remembers and includes --without development

running something else, like bundle install --without nothing should clear the cache. Am I right?

update 20150214: This is fixed in bundler 2.0, according to issue referenced in comment by @Stan Bondi (https://github.com/bundler/bundler/issues/2862). Thanks Stan.

Solution 2 - Ruby on-Rails

If you are using rails, there will be a file config written into a hidden dir called .bundle in your rails root directory:

.bundle/config

This file, in my case, held exactly the without settings.

So I just deleted the .bundle directory:

rm .bundle -r

After that:

bundle install worked again as expected.

Using: bundler (1.5.2)

Solution 3 - Ruby on-Rails

I had the same issue and --with flag worked for me. You need to pass group name, which you want to include. Like that:

bundle install --with development

Solution 4 - Ruby on-Rails

    gem 'aws-s3'
    gem 'paperclip'
      group :test do
        gem 'rspec'
        gem 'waitr'
        gem 'faker'
      end

gem 'rest-client', :group => :development
gem 'cucuber-rails', :groups => [:development,:test]  (cucuber-rails gems comes under both group)

bundle install --without development #(ignore development group gems)
bundle install #(still bundle remembers --without development so result is still ignore development groups it will not install all gems)

bundle install --without nothing #(just clearing cache, now all the gems to be loaded into the ruby loadpath)

http://madhan-tech-updates.blogspot.in/2013/02/how-to-install-gems-group-specific-in.html">More</a>

Solution 5 - Ruby on-Rails

In fact Rails loads the :development group automatically when in development environment. Check whether Rails.env in you App really returns "development".

More Information about groups in Bundler: http://gembundler.com/groups.html

Solution 6 - Ruby on-Rails

I had a similar problem - thin in staging ignored - and the solution was to put it out if staging into the 'global' space:

gem 'thin'

group :production do
  gem 'puma'
end

Solution 7 - Ruby on-Rails

I've faced the same issue with bundler 2.1.4 When I checked my .bundle/config it has

---
BUNDLE_PATH: "vendor/bundle"
BUNDLE_WITHOUT: "development:test:build"

Remove groups from there and add BUNDLE_WITH to your groups.

BUNDLE_WITH: "development"

I've removed the ~/.bundle/config. but there was a file in my project directory. .bundle/config. Local directory files have precedence over the main config files.

If you can't figure out the reason, then you can just create a file in your project directory .bundle/config. and add this content there

BUNDLE_WITH: "development:test:anyGroupYouWant"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpicardoView Question on Stackoverflow
Solution 1 - Ruby on-RailsomaView Answer on Stackoverflow
Solution 2 - Ruby on-RailsmahatmanichView Answer on Stackoverflow
Solution 3 - Ruby on-RailsVladislav LeonovView Answer on Stackoverflow
Solution 4 - Ruby on-RailsvijayaView Answer on Stackoverflow
Solution 5 - Ruby on-RailspexView Answer on Stackoverflow
Solution 6 - Ruby on-RailsMarek PříhodaView Answer on Stackoverflow
Solution 7 - Ruby on-RailsMuhammad Umair RazaView Answer on Stackoverflow