summaryrefslogtreecommitdiff
path: root/lib/rubygems/specification.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2022-03-27 13:19:49 +0200
committergit <svn-admin@ruby-lang.org>2022-06-12 02:02:20 +0900
commitd0bf31e6cffa7537ed4b69a86c58b285433143f7 (patch)
treeb944aeee6be7aada35f7c68cbce2a3ed42d38a19 /lib/rubygems/specification.rb
parent28e27ee76eb7aa79cc2b6c7fe6ce6cf3acc32dc7 (diff)
[rubygems/rubygems] Don't on gemspecs with invalid `require_paths`, just warn
These gemspecs already work most of the times. When they are installed normally, the require_paths in the gemspec stub line becomes actually correct, and the incorrect value in the real gemspec is ignored. It only becomes an issue in standalone mode. In Ruby 3.2, `Kernel#=~` has been removed, and that means that it becomes harder for us to gracefully deal with this error in standalone mode, because it now happens earlier due to calling `Array#=~` for this invalid gemspec (since require_paths is incorrectly an array of arrays). The easiest way to fix this is to actually make this just work instead by automatically fixing the issue when reading the packaged gemspec. https://github.com/rubygems/rubygems/commit/d3f2fe6d26
Diffstat (limited to 'lib/rubygems/specification.rb')
-rw-r--r--lib/rubygems/specification.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 01d3fd0eff..d8a212a04a 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1081,6 +1081,7 @@ class Gem::Specification < Gem::BasicSpecification
spec.specification_version ||= NONEXISTENT_SPECIFICATION_VERSION
spec.reset_nil_attributes_to_default
+ spec.flatten_require_paths
spec
end
@@ -2674,6 +2675,13 @@ class Gem::Specification < Gem::BasicSpecification
@installed_by_version ||= nil
end
+ def flatten_require_paths # :nodoc:
+ return unless raw_require_paths.first.is_a?(Array)
+
+ warn "#{name} #{version} includes a gemspec with `require_paths` set to an array of arrays. Newer versions of this gem might've already fixed this"
+ raw_require_paths.flatten!
+ end
+
def raw_require_paths # :nodoc:
@require_paths
end