diff options
-rw-r--r-- | lib/bundler/installer.rb | 17 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 16 | ||||
-rw-r--r-- | spec/install/gemfile/path_spec.rb | 23 | ||||
-rw-r--r-- | spec/spec_helper.rb | 1 |
4 files changed, 56 insertions, 1 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index efad66e202..ae8055408f 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -162,13 +162,28 @@ module Bundler # that said, it's a rare situation (other than rake), and parallel # installation is SO MUCH FASTER. so we let people opt in. def install(options) - Bundler.rubygems.load_plugins + load_plugins force = options["force"] jobs = 1 jobs = [Bundler.settings[:jobs].to_i - 1, 1].max if can_install_in_parallel? install_in_parallel jobs, options[:standalone], force end + def load_plugins + Bundler.rubygems.load_plugins + + requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) } + path_plugin_files = requested_path_gems.map do |spec| + begin + Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}") + rescue TypeError + error_message = "#{spec.name} #{spec.version} has an invalid gemspec" + raise Gem::InvalidSpecificationException, error_message + end + end.flatten + Bundler.rubygems.load_plugin_files(path_plugin_files) + end + def ensure_specs_are_compatible! system_ruby = Bundler::RubyVersion.system rubygems_version = Gem::Version.create(Gem::VERSION) diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 8b7ed19465..edc931e79f 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -84,6 +84,14 @@ module Bundler spec.respond_to?(:default_gem?) && spec.default_gem? end + def spec_matches_for_glob(spec, glob) + return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob) + + spec.load_paths.map do |lp| + Dir["#{lp}/#{glob}#{suffix_pattern}"] + end.flatten(1) + end + def stub_set_spec(stub, spec) stub.instance_variable_set(:@spec, spec) end @@ -158,6 +166,10 @@ module Bundler Gem.post_reset_hooks end + def suffix_pattern + Gem.suffix_pattern + end + def gem_cache gem_path.map {|p| File.expand_path("cache", p) } end @@ -212,6 +224,10 @@ module Bundler Gem.load_plugins if Gem.respond_to?(:load_plugins) end + def load_plugin_files(files) + Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files) + end + def ui=(obj) Gem::DefaultUserInteraction.ui = obj end diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index 49dda37aee..e76d5c486e 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -590,5 +590,28 @@ RSpec.describe "bundle install with explicit source paths" do :requires => [lib_path("install_hooks.rb")] expect(out).to include("failed for foo-1.0") end + + it "loads plugins from the path gem" do + foo_file = home("foo_plugin_loaded") + bar_file = home("bar_plugin_loaded") + expect(foo_file).not_to be_file + expect(bar_file).not_to be_file + + build_lib "foo" do |s| + s.write("lib/rubygems_plugin.rb", "FileUtils.touch('#{foo_file}')") + end + + build_git "bar" do |s| + s.write("lib/rubygems_plugin.rb", "FileUtils.touch('#{bar_file}')") + end + + install_gemfile! <<-G + gem "foo", :path => "#{lib_path("foo-1.0")}" + gem "bar", :path => "#{lib_path("bar-1.0")}" + G + + expect(foo_file).to be_file + expect(bar_file).to be_file + end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f9285463b5..f6700ca315 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,7 @@ begin rspec = spec.dependencies.find {|d| d.name == "rspec" } gem "rspec", rspec.requirement.to_s require "rspec" + require "diff/lcs" rescue LoadError abort "Run rake spec:deps to install development dependencies" end |