From 8240fe88f32ff4fec54cb6c425782597efa4d397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 14 Oct 2024 19:55:38 +0200 Subject: [PATCH] [rubygems/rubygems] Prevent some test suite warnings about missing extensions We fixed some issues recently where Bundler would try to activate a pysch spec with missing extensions and crash. However, as a side effect, we started printing warnings about missing extensions in situations where we did not warn before. It may be interesting to warn on these new situations too, but in order to minimize changes for now, I'm reverting to printing warnings in the same situations as before. https://github.com/rubygems/rubygems/commit/51ebff6982 --- lib/bundler/rubygems_ext.rb | 12 ++++++------ lib/rubygems/basic_specification.rb | 17 ++++++++--------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index 547102be41..296bcfff38 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -384,13 +384,13 @@ module Gem end end - remove_method :ignored? if new.respond_to?(:ignored?) + # Can be removed once RubyGems 3.5.22 support is dropped + unless new.respond_to?(:ignored?) + def ignored? + return @ignored unless @ignored.nil? - # Same as RubyGems, but without warnings, because Bundler prints its own warnings - def ignored? - return @ignored unless @ignored.nil? - - @ignored = missing_extensions? + @ignored = missing_extensions? + end end end diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index 8c75fd41d4..a09e8ed0e1 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -71,7 +71,14 @@ class Gem::BasicSpecification # Return true if this spec can require +file+. def contains_requirable_file?(file) - return false if ignored? + if 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 + + return false + end is_soext = file.end_with?(".so", ".o") @@ -89,14 +96,6 @@ class Gem::BasicSpecification 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?