Skip to content

Commit 0d321c9

Browse files
Fix Ruby platform incorrectly removed on bundle update
1 parent 69d6268 commit 0d321c9

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

bundler/lib/bundler/definition.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ def remove_ruby_from_platforms_if_necessary!(dependencies)
888888
Bundler.local_platform == Gem::Platform::RUBY ||
889889
!platforms.include?(Gem::Platform::RUBY) ||
890890
(@new_platform && platforms.last == Gem::Platform::RUBY) ||
891-
!@originally_locked_specs.incomplete_ruby_specs?(dependencies)
891+
!@originally_locked_specs.incomplete_ruby_specs?(expand_dependencies(dependencies))
892892

893893
remove_platform(Gem::Platform::RUBY)
894894
add_current_platform

bundler/spec/install/gemfile/specific_platform_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,47 @@
445445
L
446446
end
447447

448+
it "does not remove ruby if gems for other platforms, and not present in the lockfile, exist in the Gemfile" do
449+
build_repo4 do
450+
build_gem "nokogiri", "1.13.8"
451+
build_gem "nokogiri", "1.13.8" do |s|
452+
s.platform = Gem::Platform.local
453+
end
454+
end
455+
456+
gemfile <<~G
457+
source "#{file_uri_for(gem_repo4)}"
458+
459+
gem "nokogiri"
460+
461+
gem "tzinfo", "~> 1.2", platform: :#{not_local_tag}
462+
G
463+
464+
original_lockfile = <<~L
465+
GEM
466+
remote: #{file_uri_for(gem_repo4)}/
467+
specs:
468+
nokogiri (1.13.8)
469+
nokogiri (1.13.8-#{Gem::Platform.local})
470+
471+
PLATFORMS
472+
#{lockfile_platforms_for([specific_local_platform, "ruby"])}
473+
474+
DEPENDENCIES
475+
nokogiri
476+
tzinfo (~> 1.2)
477+
478+
BUNDLED WITH
479+
#{Bundler::VERSION}
480+
L
481+
482+
lockfile original_lockfile
483+
484+
bundle "lock --update"
485+
486+
expect(lockfile).to eq(original_lockfile)
487+
end
488+
448489
it "can fallback to a source gem when platform gems are incompatible with current ruby version" do
449490
setup_multiplatform_gem_with_source_gem
450491

0 commit comments

Comments
 (0)