diff options
| author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2024-10-04 18:21:41 +0200 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-10-10 14:51:32 +0000 |
| commit | 3fdf0e7e6deee8a275869c1ced389f6e4d9975ea (patch) | |
| tree | 100fef3d15c29a70f0abf98032c02ec67c00f827 /lib | |
| parent | f63873e7a2d07e23694148ea500da3baf09cc680 (diff) | |
[rubygems/rubygems] Fix specs with missing extensions getting activated
https://github.com/rubygems/rubygems/commit/c80998a22a
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bundler/rubygems_ext.rb | 19 | ||||
| -rw-r--r-- | lib/bundler/source/rubygems.rb | 5 | ||||
| -rw-r--r-- | lib/bundler/stub_specification.rb | 11 | ||||
| -rw-r--r-- | lib/rubygems/basic_specification.rb | 30 | ||||
| -rw-r--r-- | lib/rubygems/dependency.rb | 2 |
5 files changed, 50 insertions, 17 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index a3f70e9a3c..14f10af9d7 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -269,6 +269,16 @@ module Gem end out end + + if Gem.rubygems_version < Gem::Version.new("3.5.22") + module FilterIgnoredSpecs + def matching_specs(platform_only = false) + super.reject(&:ignored?) + end + end + + prepend FilterIgnoredSpecs + end end require "rubygems/platform" @@ -374,6 +384,15 @@ module Gem end end end + + remove_method :ignored? if new.respond_to?(:ignored?) + + # Same as RubyGems, but without warnings, because Bundler prints its own warnings + def ignored? + return @ignored unless @ignored.nil? + + @ignored = missing_extensions? + end end require "rubygems/name_tuple" diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 4219bda3bd..36185561fa 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -357,10 +357,7 @@ module Bundler @installed_specs ||= Index.build do |idx| Bundler.rubygems.installed_specs.reverse_each do |spec| spec.source = self - if spec.missing_extensions? - Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions" - next - end + next if spec.ignored? idx << spec end end diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb index dc5d38580a..718920f091 100644 --- a/lib/bundler/stub_specification.rb +++ b/lib/bundler/stub_specification.rb @@ -28,6 +28,17 @@ module Bundler # @!group Stub Delegates + def ignored? + return @ignored unless @ignored.nil? + + @ignored = missing_extensions? + return false unless @ignored + + warn "Source #{source} is ignoring #{self} because it is missing extensions" + + true + end + def manually_installed? # This is for manually installed gems which are gems that were fixed in place after a # failed installation. Once the issue was resolved, the user then manually created diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index 204231e95e..ccd3e49cea 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -71,18 +71,7 @@ class Gem::BasicSpecification # Return true if this spec can require +file+. def contains_requirable_file?(file) - if @ignored - return false - elsif missing_extensions? - @ignored = true - - if platform == Gem::Platform::RUBY || Gem::Platform.local === platform - warn "Ignoring #{full_name} because its extensions are not built. " \ - "Try: gem pristine #{name} --version #{version}" - end - - return false - end + return false if ignored? is_soext = file.end_with?(".so", ".o") @@ -93,6 +82,23 @@ class Gem::BasicSpecification end end + ## + # Return true if this spec should be ignored because it's missing extensions. + + def ignored? + return @ignored unless @ignored.nil? + + @ignored = missing_extensions? + return false unless @ignored + + if platform == Gem::Platform::RUBY || Gem::Platform.local === platform + warn "Ignoring #{full_name} because its extensions are not built. " \ + "Try: gem pristine #{name} --version #{version}" + end + + true + end + def default_gem? loaded_from && File.dirname(loaded_from) == Gem.default_specifications_dir diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb index ecb4824d7e..d1ec9222af 100644 --- a/lib/rubygems/dependency.rb +++ b/lib/rubygems/dependency.rb @@ -279,7 +279,7 @@ class Gem::Dependency end end - matches + matches.reject(&:ignored?) end ## |
