Skip to content

Commit bf6b8dd

Browse files
deivid-rodriguezmatzbot
authored andcommitted
[rubygems/rubygems] Fix bundle update <gem_name> edge case
When locked only to RUBY, and some locked spec does not meet locked dependencies, Bundler would remove the only locked platform and end up creating a lockfile with empty sections. We can't rely on our criteria to remove invalid platforms if locked specs are not valid in the first place. rubygems/rubygems@1dba05cf53
1 parent f445d54 commit bf6b8dd

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

lib/bundler/definition.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,7 @@ def remove_invalid_platforms!(dependencies)
10581058
(@new_platform && platforms.last == platform) ||
10591059
@path_changes ||
10601060
@dependency_changes ||
1061+
@locked_spec_with_invalid_deps ||
10611062
!@originally_locked_specs.incomplete_for_platform?(dependencies, platform)
10621063

10631064
remove_platform(platform)

spec/bundler/install/gemfile/specific_platform_spec.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,63 @@
844844
end
845845
end
846846

847+
it "automatically fixes the lockfile if locked only to RUBY, and some locked specs don't meed locked dependencies" do
848+
simulate_platform "x86_64-linux" do
849+
build_repo4 do
850+
build_gem("ibandit", "0.7.0") do |s|
851+
s.add_runtime_dependency "i18n", "~> 0.7.0"
852+
end
853+
854+
build_gem("i18n", "0.7.0.beta1")
855+
build_gem("i18n", "0.7.0")
856+
end
857+
858+
gemfile <<~G
859+
source "#{file_uri_for(gem_repo4)}"
860+
861+
gem "ibandit", "~> 0.7.0"
862+
G
863+
864+
lockfile <<~L
865+
GEM
866+
remote: #{file_uri_for(gem_repo4)}/
867+
specs:
868+
i18n (0.7.0.beta1)
869+
ibandit (0.7.0)
870+
i18n (~> 0.7.0)
871+
872+
PLATFORMS
873+
ruby
874+
875+
DEPENDENCIES
876+
ibandit (~> 0.7.0)
877+
878+
BUNDLED WITH
879+
#{Bundler::VERSION}
880+
L
881+
882+
bundle "lock --update i18n"
883+
884+
expect(lockfile).to eq <<~L
885+
GEM
886+
remote: #{file_uri_for(gem_repo4)}/
887+
specs:
888+
i18n (0.7.0)
889+
ibandit (0.7.0)
890+
i18n (~> 0.7.0)
891+
892+
PLATFORMS
893+
ruby
894+
895+
DEPENDENCIES
896+
ibandit (~> 0.7.0)
897+
898+
BUNDLED WITH
899+
#{Bundler::VERSION}
900+
L
901+
end
902+
end
903+
847904
it "does not remove ruby if gems for other platforms, and not present in the lockfile, exist in the Gemfile" do
848905
build_repo4 do
849906
build_gem "nokogiri", "1.13.8"

0 commit comments

Comments
 (0)