From 4a26833878efb93209a3e8b0c2bc07d6a5094c42 Mon Sep 17 00:00:00 2001 From: Ivan Kuchin Date: Sat, 5 Sep 2020 19:16:12 +0200 Subject: [PATCH] Backport the fix to bundler to work with older versions of rubygems --- bundler/lib/bundler/rubygems_ext.rb | 27 +++++++++++++++++++ bundler/spec/install/gemfile/platform_spec.rb | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bundler/lib/bundler/rubygems_ext.rb b/bundler/lib/bundler/rubygems_ext.rb index 1d3bdc5565be..36e5dd49a6de 100644 --- a/bundler/lib/bundler/rubygems_ext.rb +++ b/bundler/lib/bundler/rubygems_ext.rb @@ -129,6 +129,33 @@ def to_lock end end + unless Gem::Requirement.new('> 1', '< 2') == Gem::Requirement.new('< 2', '> 1') + class Requirement + module OrderIndependentComparison + def ==(other) + if _sorted_requirements? && other._sorted_requirements? + super + else + _with_sorted_requirements == other._with_sorted_requirements + end + end + + protected + + def _sorted_requirements? + strings = as_list + strings == strings.sort + end + + def _with_sorted_requirements + @_with_sorted_requirements ||= self.class.new(as_list.sort) + end + end + + prepend OrderIndependentComparison + end + end + class Platform JAVA = Gem::Platform.new("java") unless defined?(JAVA) MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN) diff --git a/bundler/spec/install/gemfile/platform_spec.rb b/bundler/spec/install/gemfile/platform_spec.rb index 199d61f4d868..545b44507b4e 100644 --- a/bundler/spec/install/gemfile/platform_spec.rb +++ b/bundler/spec/install/gemfile/platform_spec.rb @@ -256,7 +256,7 @@ expect(the_bundle).not_to include_gem "CFPropertyList" end - it "works with gems with platform-specific dependency having different requirements order", :rubygems => ">= 3.2.0.rc.2" do + it "works with gems with platform-specific dependency having different requirements order" do simulate_platform x64_mac update_repo2 do