summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVít Ondruch <vondruch@redhat.com>2014-11-05 16:36:14 +0100
committerVít Ondruch <vondruch@redhat.com>2014-12-05 16:29:58 +0100
commitb951539ed50db8c6b2d6eb1fe73e82070b387fe2 (patch)
tree76b6c0bf9759c318354a658c760ce2945a4805d1
parent0ff452a5e37661c69ed0e82b200f74a70ba97525 (diff)
downloadbundler-b951539ed50db8c6b2d6eb1fe73e82070b387fe2.tar.gz
Fix RubyGems 2.2+ compatibility.
RubyGems since version 2.2 allows to reconfigure place, where binary extensions are stored. This might allow easier sharing of gems between various Ruby interpreters. It can be enabled by redefining Gem.default_ext_dir_for method. This patch is adding support for this feature into Bundler.
-rw-r--r--lib/bundler/shared_helpers.rb20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 0a6435eaa3..0a5b3ea2c8 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -98,10 +98,22 @@ module Bundler
# handle 1.9 where system gems are always on the load path
if defined?(::Gem)
me = File.expand_path("../../", __FILE__)
- $LOAD_PATH.reject! do |p|
- next if File.expand_path(p) =~ /^#{Regexp.escape(me)}/
- p != File.dirname(__FILE__) &&
- Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{Regexp.escape(gp)}/ }
+
+ # RubyGems 2.2+ can put binary extension into dedicated folders,
+ # therefore use RubyGems facilities to obtain their load paths.
+ if Gem::Specification.method_defined? :full_require_paths
+ loaded_gem_paths = Gem.loaded_specs.map do |n, s|
+ s.full_require_paths.none? {|path| File.expand_path(path) =~ /^#{Regexp.escape(me)}/} ? s.full_require_paths : []
+ end
+ loaded_gem_paths.flatten!
+
+ $LOAD_PATH.reject! {|p| loaded_gem_paths.delete(p) }
+ else
+ $LOAD_PATH.reject! do |p|
+ next if File.expand_path(p) =~ /^#{Regexp.escape(me)}/
+ p != File.dirname(__FILE__) &&
+ Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{Regexp.escape(gp)}/ }
+ end
end
$LOAD_PATH.uniq!
end