diff options
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 9 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 8 | ||||
-rw-r--r-- | man/bundle-config.ronn | 2 | ||||
-rw-r--r-- | spec/install/gemfile/git_spec.rb | 6 | ||||
-rw-r--r-- | spec/install/path_spec.rb | 28 |
5 files changed, 47 insertions, 6 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index ec1a408715..8ec9df53e8 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -71,8 +71,13 @@ module Bundler spec.installed_by_version = Gem::Version.create(installed_by_version) end - def spec_missing_extensions?(spec) - !spec.respond_to?(:missing_extensions?) || spec.missing_extensions? + def spec_missing_extensions?(spec, default = true) + return spec.missing_extensions? if spec.respond_to?(:missing_extensions?) + + return false if spec.respond_to?(:default_gem?) && spec.default_gem? + return false if spec.extensions.empty? + + default end def path(obj) diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 89f7673eb8..53d3a84fb0 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -292,6 +292,10 @@ module Bundler next if spec.name == "bundler" && spec.version.to_s != VERSION have_bundler = true if spec.name == "bundler" spec.source = self + if Bundler.rubygems.spec_missing_extensions?(spec, false) + Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions" + next + end idx << spec end @@ -322,6 +326,10 @@ module Bundler next if gemfile =~ /^bundler\-[\d\.]+?\.gem/ s ||= Bundler.rubygems.spec_from_gem(gemfile) s.source = self + if Bundler.rubygems.spec_missing_extensions?(s, false) + Bundler.ui.debug "Source #{self} is ignoring #{s} because it is missing extensions" + next + end idx << s end end diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn index 5f10aaa658..cb9fc6cc00 100644 --- a/man/bundle-config.ronn +++ b/man/bundle-config.ronn @@ -65,7 +65,7 @@ The options that can be configured are: The location to install the specified gems to. This defaults to Rubygems' setting. Bundler shares this location with Rubygems, `gem install ...` will have gem installed there, too. Therefore, gems installed without a - `--path ...` setting will show up by calling `gem list`. Accodingly, gems + `--path ...` setting will show up by calling `gem list`. Accordingly, gems installed to other locations will not get listed. * `without`: diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index f70ea5b43a..85a7693b5a 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -1022,20 +1022,20 @@ describe "bundle install with git sources" do gem "foo", :git => "#{lib_path("foo-1.0")}" G - run <<-R + run! <<-R require 'foo' puts FOO R installed_time = out - expect(installed_time).to match(/\d+\.\d+/) + expect(installed_time).to match(/\A\d+\.\d+\z/) install_gemfile <<-G source "file://#{gem_repo1}" gem "foo", :git => "#{lib_path("foo-1.0")}" G - run <<-R + run! <<-R require 'foo' puts FOO R diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb index 0a961981b3..9a8d61ea47 100644 --- a/spec/install/path_spec.rb +++ b/spec/install/path_spec.rb @@ -128,6 +128,34 @@ describe "bundle install" do expect(vendored_gems("gems/rack-1.0.0")).to be_directory expect(the_bundle).to include_gems "rack 1.0.0" end + + it "re-installs gems whose extensions have been deleted", :rubygems => ">= 2.3" do + build_lib "very_simple_binary", "1.0.0", :to_system => true do |s| + s.write "lib/very_simple_binary.rb", "raise 'FAIL'" + end + + gemfile <<-G + source "file://#{gem_repo1}" + gem "very_simple_binary" + G + + bundle "install --path ./vendor/bundle" + + expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory + expect(vendored_gems("extensions")).to be_directory + expect(the_bundle).to include_gems "very_simple_binary 1.0", :source => "remote1" + + vendored_gems("extensions").rmtree + + run "require 'very_simple_binary_c'" + expect(err).to include("Bundler::GemNotFound") + + bundle "install --path ./vendor/bundle" + + expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory + expect(vendored_gems("extensions")).to be_directory + expect(the_bundle).to include_gems "very_simple_binary 1.0", :source => "remote1" + end end describe "to a file" do |