diff options
author | Hsing-Hui Hsu <hsing-hui@carezone.com> | 2016-02-02 20:54:01 -0800 |
---|---|---|
committer | Hsing-Hui Hsu <hsing-hui@carezone.com> | 2016-02-02 21:32:22 -0800 |
commit | c47d453219bf6488446b05f9ba7386fc6e9c249f (patch) | |
tree | 8068bd17695e9cc7431003b855b3547a76b112bf /lib | |
parent | 09782996ee4811d140e19e6bc711e0463ae21cd2 (diff) | |
download | bundler-c47d453219bf6488446b05f9ba7386fc6e9c249f.tar.gz |
Place bundler loaded gems after -I and RUBYLIB
Previously, gems were being placed at the front of the LOAD_PATH. This
meant you couldn't override a gem by setting -I or RUBYLIB.
This patch places -I and RUBYLIB in front of loaded gems and matches the
behavior in RubyGems.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/runtime.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 6ef476b9dc..0b1e5f92b5 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -37,7 +37,17 @@ module Bundler Bundler.rubygems.mark_loaded(spec) load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path) } - $LOAD_PATH.unshift(*load_paths) + + # See Gem::Specification#add_self_to_load_path (since RubyGems 1.8) + insert_index = Gem.load_path_insert_index + + if insert_index + # Gem directories must come after -I and ENV['RUBYLIB'] + $LOAD_PATH.insert(insert_index, *load_paths) + else + # We are probably testing in core, -I and RUBYLIB don't apply + $LOAD_PATH.unshift(*load_paths) + end end setup_manpath |