Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell bundler to ignore gems that don't exist?

My organization has a number of in-house gems that are used in automated testing, but are not required for a production deployment. I am trying to use Bundler and so in my Gemfile I've wrapped those gems in:

group :test, :development do
    gem 'dashboard_summary'
end

However, when I run:

$ bundle install --without staging development test

I still get

Could not find gem 'dashboard_summary (>= 0) ruby' in the gems available on this machine.

I'm trying to understand why Bundler isn't ignoring that gem when I've told it to.

like image 967
spierepf Avatar asked May 24 '13 19:05

spierepf


3 Answers

This is expected behaviour. From the docs:

While the --without option will skip installing the gems in the specified groups, it will still download those gems and use them to resolve the dependencies of every gem in your Gemfile(5).

Whilst an up to date Gemfile.lock might suggest that the dependencies don’t need to be resolved again, it looks like all gems are downloaded even in this case.

like image 188
matt Avatar answered Oct 22 '22 13:10

matt


You didn't define any group that includes staging, development and test. Your group only had test and development.

Bundler is trying to ignore a group which has all three name in it, so you can add staging to

group :test, :development, :staging do
    gem 'dashboard_summary'
end

or you can use

 $ bundle install --without test development
like image 28
Anil Maurya Avatar answered Oct 22 '22 15:10

Anil Maurya


I'm not sure why you have staging in there? but this should work

 bundle install --without test development

You could also set the config environment variable documented in BUNDLE_WITHOUT in bundle config.

You could use

gem 'dashboard_summary', require: false

This would not load the gem on startup and you would have to require it when you wanted to use the gem. This may help if you need to keep dashboard_summary in your Gemfile because of dependencies, but save the time it takes to load and not get the error you are getting now. It's at least something to try.

like image 23
fontno Avatar answered Oct 22 '22 14:10

fontno