summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-03-24 18:19:29 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-03-31 09:39:22 +0900
commitb2bcd360441c334f16148908684e9b409eac4949 (patch)
treebd5775a0370646b3e3a2cb0a93e9f28868366228
parentf72d5effb79a9957a0abd62c4f743e67cbf8e5ed (diff)
[rubygems/rubygems] Remove edge cases for not removing invalid platforms
Instead, remove them anytime we find dependencies don't match the lockfile for a platform, and then add them back after resolution if they ended up being valid. https://github.com/rubygems/rubygems/commit/220bd77887
-rw-r--r--lib/bundler/definition.rb15
-rw-r--r--lib/bundler/spec_set.rb6
-rw-r--r--spec/bundler/commands/update_spec.rb2
3 files changed, 16 insertions, 7 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 6f51168bcc..d57a9704d8 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -95,6 +95,7 @@ module Bundler
@locked_ruby_version = nil
@new_platforms = []
@removed_platforms = []
+ @originally_invalid_platforms = []
if lockfile_exists?
@lockfile_contents = Bundler.read_file(lockfile)
@@ -760,7 +761,11 @@ module Bundler
end
end
- result.add_extra_platforms!(platforms) if should_add_extra_platforms?
+ if should_add_extra_platforms?
+ result.add_extra_platforms!(platforms)
+ elsif @originally_invalid_platforms.any?
+ result.add_originally_invalid_platforms!(platforms, @originally_invalid_platforms)
+ end
SpecSet.new(result.for(dependencies, @platforms | [Gem::Platform::RUBY]))
end
@@ -1137,17 +1142,15 @@ module Bundler
def remove_invalid_platforms!
return if Bundler.frozen_bundle?
- invalid_platforms = platforms.select do |platform|
+ @originally_invalid_platforms = platforms.select do |platform|
next if local_platform == platform ||
@new_platforms.include?(platform) ||
- @path_changes ||
- @dependency_changes ||
- @locked_spec_with_invalid_deps
+ @dependency_changes
spec_set_incomplete_for_platform?(@originally_locked_specs, platform)
end
- @platforms -= invalid_platforms
+ @platforms -= @originally_invalid_platforms
end
def spec_set_incomplete_for_platform?(spec_set, platform)
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index 1de31da4cf..de361845fe 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -47,6 +47,12 @@ module Bundler
end.uniq
end
+ def add_originally_invalid_platforms!(platforms, originally_invalid_platforms)
+ originally_invalid_platforms.each do |originally_invalid_platform|
+ platforms << originally_invalid_platform if complete_platform(originally_invalid_platform)
+ end
+ end
+
def add_extra_platforms!(platforms)
if @specs.empty?
platforms.concat([Gem::Platform::RUBY]).uniq
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index 078bb254a4..c6ab0dcf14 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -640,7 +640,7 @@ RSpec.describe "bundle update" do
myrack
PLATFORMS
- #{local_platform}
+ x86-darwin-100
DEPENDENCIES
activesupport