2

I have the following Gemfile

source "http://rubygems.org"

gem "bundler", "1.10.6"
gem "unicorn", "4.8.2"

group :supply do
  gem "backup", "4.1.10"
end

group :bunker do
  gem "capistrano", "3.4.0"
  gem "capistrano-rbenv", "2.0.3"
  gem "capistrano-bundler", "1.1.4"
  gem "capistrano-rails", "1.1.3"
  gem "capistrano-nc", "0.1.4"
end

group :reinforcement do
  gem "actionview", "4.2.1"
  gem "actionmailer", "4.2.1"
  gem "mail", "2.6.3"
  gem "daemons", "1.2.3"
  gem "tmail", "1.2.7.1"
  gem "activerecord", "4.2.1"
  gem "starling", "0.10.1"
end

I have many type of servers and want to install specific gems on specific servers eg. backup gem only on supply server etc.

When I run the following bundle install command

bundle install --clean --without supply bunker --path /tmp/

I am getting the following error.

Bundler could not find compatible versions for gem "mail":
  In Gemfile:
    mail (>= 2.5.4, ~> 2.5) ruby

    backup (= 4.1.10) ruby depends on
      mail (= 2.5.4) ruby

    mail (= 2.6.3) ruby

If without is to exclude gem of certain group then the command should run just fine because it should never try to install mail and backup because they are not in the same group.

Am I missing something or doing anything wrong?

bitkot
  • 4,466
  • 2
  • 28
  • 39
  • Your example is flawed. You don't exclude the `reinforcement` group that references the `mail` gem. – Mihai Dinculescu Feb 17 '16 at 10:50
  • @Mihai-AndreiDinculescu, But I excluded `supply` group that means it should try to install `backup` gem. – bitkot Feb 17 '16 at 10:54
  • But your error message says that `backup` depends on `mail`. – Mihai Dinculescu Feb 17 '16 at 11:03
  • Correct, when there is dependency bundle will install specific version required by the gem eg. `backup` depends on `mail=2.5.4`, the conflict here is that it also tries to install `mail` gem version `2.6.3` which is in different group and is excluded. – bitkot Feb 17 '16 at 11:24

1 Answers1

0

Found that bundler checks for conflict even between group for consistency.

Here's an article checkout the Consistency part.

This means that even though bundler will not install the gems in other group it will still make sure that there is no conflicting dependencies between gems in all the groups.

I had to create multiple Gemfile and Gemfile.lock for each server.

bitkot
  • 4,466
  • 2
  • 28
  • 39