summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2024-07-18 00:06:26 +0200
committergit <svn-admin@ruby-lang.org>2024-07-18 09:25:16 +0000
commit95728a8b4208bb9a3427cde95a4ceba76e349b39 (patch)
treeb02d42d222dc255016b05fbe4adac7113b248f8f
parentf78a8761c4e8ea679b7b6352880b8b53714687ae (diff)
[rubygems/rubygems] Warn non flattened require paths in old RubyGems versions too
https://github.com/rubygems/rubygems/commit/b3cdccc6fb
-rw-r--r--lib/bundler/rubygems_ext.rb24
-rw-r--r--spec/bundler/realworld/edgecases_spec.rb13
2 files changed, 25 insertions, 12 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 503959bba7..3d53368659 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -56,6 +56,9 @@ module Gem
# Can be removed once RubyGems 3.5.14 support is dropped
VALIDATES_FOR_RESOLUTION = Specification.new.respond_to?(:validate_for_resolution).freeze
+ # Can be removed once RubyGems 3.3.15 support is dropped
+ FLATTENS_REQUIRED_PATHS = Specification.new.respond_to?(:flatten_require_paths).freeze
+
class Specification
require_relative "match_metadata"
require_relative "match_platform"
@@ -161,6 +164,27 @@ module Gem
end
end
+ unless FLATTENS_REQUIRED_PATHS
+ def flatten_require_paths
+ 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
+
+ class << self
+ module RequirePathFlattener
+ def from_yaml(input)
+ spec = super(input)
+ spec.flatten_require_paths
+ spec
+ end
+ end
+
+ prepend RequirePathFlattener
+ end
+ end
+
private
def dependencies_to_gemfile(dependencies, group = nil)
diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb
index 94ca3554b1..dc15c56c79 100644
--- a/spec/bundler/realworld/edgecases_spec.rb
+++ b/spec/bundler/realworld/edgecases_spec.rb
@@ -198,18 +198,7 @@ RSpec.describe "real world edgecases", realworld: true do
expect(lockfile).to include(rubygems_version("paperclip", "~> 5.1.0"))
end
- it "outputs a helpful error message when gems have invalid gemspecs", rubygems: "< 3.3.16" do
- install_gemfile <<-G, standalone: true, raise_on_error: false, env: { "BUNDLE_FORCE_RUBY_PLATFORM" => "1" }
- source 'https://rubygems.org'
- gem "resque-scheduler", "2.2.0"
- gem "redis-namespace", "1.6.0" # for a consistent resolution including ruby 2.3.0
- gem "ruby2_keywords", "0.0.5"
- G
- expect(err).to include("You have one or more invalid gemspecs that need to be fixed.")
- expect(err).to include("resque-scheduler 2.2.0 has an invalid gemspec")
- end
-
- it "outputs a helpful warning when gems have a gemspec with invalid `require_paths`", rubygems: ">= 3.3.16" do
+ it "outputs a helpful warning when gems have a gemspec with invalid `require_paths`" do
install_gemfile <<-G, standalone: true, env: { "BUNDLE_FORCE_RUBY_PLATFORM" => "1" }
source 'https://rubygems.org'
gem "resque-scheduler", "2.2.0"