aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler/runtime.rb
diff options
context:
space:
mode:
authorHsing-Hui Hsu <hsing-hui@carezone.com>2016-02-02 20:54:01 -0800
committerHsing-Hui Hsu <hsing-hui@carezone.com>2016-02-02 21:32:22 -0800
commitc47d453219bf6488446b05f9ba7386fc6e9c249f (patch)
tree8068bd17695e9cc7431003b855b3547a76b112bf /lib/bundler/runtime.rb
parent09782996ee4811d140e19e6bc711e0463ae21cd2 (diff)
downloadbundler-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/bundler/runtime.rb')
-rw-r--r--lib/bundler/runtime.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index 6ef476b9..0b1e5f92 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