set BUNDLE_GEMFILE before requiring bundler

Fixes #2721
This commit is contained in:
Colin Surprenant 2015-02-27 18:26:16 -05:00 committed by Jordan Sissel
parent 0c0a6b6f07
commit 4319119e60

View file

@ -94,16 +94,19 @@ module LogStash
# make sure we use our own nicely installed bundler and not a rogue, bad, mean, ugly, stupid other bundler. bad bundler, bad bad bundler go away.
Gem.clear_paths
Gem.paths = ENV['GEM_HOME'] = ENV['GEM_PATH'] = logstash_gem_home
# set BUNDLE_GEMFILE ENV before requiring bundler to avoid bundler recurse and load unrelated Gemfile(s)
ENV["BUNDLE_GEMFILE"] = LogStash::Environment::GEMFILE_PATH
require "bundler"
require "logstash/bundler"
::Bundler.settings[:path] = LogStash::Environment::BUNDLE_DIR
::Bundler.settings[:without] = "development"
# in the context of Bundler.setup it looks like this is useless here because Gemfile path can only be specified using
# the ENV, see https://github.com/bundler/bundler/blob/v1.8.3/lib/bundler/shared_helpers.rb#L103
::Bundler.settings[:gemfile] = LogStash::Environment::GEMFILE_PATH
# also set ENV because bundler does not check settings for :gemfile here
# https://github.com/bundler/bundler/blob/v1.8.3/lib/bundler/shared_helpers.rb#L103
ENV["BUNDLE_GEMFILE"] = LogStash::Environment::GEMFILE_PATH
::Bundler.reset!
::Bundler.setup