Bundler-inject gem


#1

Hi all,

We recently merged the changes to extract our override_gem capability into a new gem called bundler-inject. You probably won’t even notice any changes, but I wanted to show new features we’ve added that might be useful for you. If you want to read about everything in a little more depth, check out the project README.

~/.bundler.d

As you may be aware, the bundler.d directory in the ManageIQ project is where you can put your custom gemfiles to add your own development gems, or override existing gems. bundler-inject will now also look in ~/.bundler.d for custom gemfiles. This allows you to specify your common development gems in a single place, which is very useful as bundler-inject starts getting used in more repos.

ensure_gem

Of course with all new features comes more problems. When using a global gemfile there is a case where if you specify gem and the project’s Gemfile already has the gem declared, you get a “gem declared twice” warning. You may think you could “fix” that warning with override_gem in your global gemfile, but when you switch to another repo that doesn’t have that gem declared, you get a “can’t override gem” error. To deal with these cases, we’ve introduced a new helper method ensure_gem. This method is a less forceful version of override_gem that will defer to the project’s gem declaration if it exists, but will still override if you specify a path/git/version difference.

disable_warn_override_gem

The warning emitted when you override a gem is not always wanted. We’ve introduced a bundler setting to allow disabling it. Just do one of the following:

bundle config bundler_inject.disable_warn_override_gem true
# OR
export BUNDLE_BUNDLER_INJECT__DISABLE_WARN_OVERRIDE_GEM=true

#2

Love the “What is this sorcery?” and “Development” sections in the README :heart:
At last, I learnt why Gemfile code is executed 2 times.