summaryrefslogtreecommitdiff
path: root/lib/bundler/runtime.rb
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-02-11 10:22:12 +0900
committerHomu <homu@barosl.com>2016-02-11 10:22:12 +0900
commit1c2710639ccd8558c8467bb3cd2f95548306bc31 (patch)
treeaff7df7055e89b03791d63ea24379adb7685d266 /lib/bundler/runtime.rb
parente220788471bd0f489e239aaf6e6ecdccf997cf53 (diff)
parent10ccab6a0dae411d722925fb9030475fd315db01 (diff)
downloadbundler-1c2710639ccd8558c8467bb3cd2f95548306bc31.tar.gz
Auto merge of #4268 - Elffers:hhh_fix_ruby-I, r=indirect
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 c2d5ad4b0a..e80a9eaeba 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 = Bundler.rubygems.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