dan-klasson dan-klasson - 7 months ago 13
Ruby Question

Bundler ignoring 'without' group

I'm trying to include gems from my local instead of the gemserver on development. My Gemfile looks like this:

group :development do
gem "appy_core", path: "../engines/core"
end

group :production do
gem "appy_core", '1.7.4.5'
end


My
.bundle/config
is set to:

---
BUNDLE_WITHOUT: production


Yet when I run
bundle
I get:

[!] There was an error parsing `Gemfile`: You cannot specify the same gem twice with different version requirements.
You specified: appy_core (>= 0) and appy_core (= 1.7.4.5). Bundler cannot continue.


Running
bundle install --without production
produces the same result.

Answer

The only solution I came up with / am aware of:

in Gemfile:

gem 'appy_core', 
    git: 'git://github.com/.......',
    branch: '1.7.4.5' # put the name of the branch that corresponds

in local environment’s shell:

$ bundle config local.appy_core /path/to/engines/core

Now do whatever you want in the local branch, commit it locally and enjoy.


Hack that works

Since Gemfile is plain ruby, one might use ruby features there:

somewhere in permanent shell settings:

alias bundle="USE_DEV_VERSION=1 bundle"

in Gemfile:

if ENV['USE_DEV_VERSION']
  gem "appy_core", path: "../engines/core"
else
  gem "appy_core", '1.7.4.5'
end

Now bundle install will use dev version locally and the standard gem outside of the “patched” environment.