File tree 4 files changed +50
-6
lines changed
4 files changed +50
-6
lines changed Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ def after_install_all(install: true)
217
217
end
218
218
219
219
# add a source for the current gem
220
- gem_spec = parent_specs [ [ File . basename ( Bundler . root ) , "ruby" ] ]
220
+ gem_spec = parent_specs . dig ( File . basename ( Bundler . root ) , "ruby" )
221
221
222
222
if gem_spec
223
223
adjusted_parent_lockfile_contents += <<~TEXT
@@ -257,9 +257,8 @@ def after_install_all(install: true)
257
257
258
258
# replace any duplicate specs with what's in the parent lockfile
259
259
lockfile . specs . map! do |spec |
260
- parent_spec = parent_specs [ [ spec . name , spec . platform ] ]
260
+ parent_spec = cache . find_matching_spec ( parent_specs , spec )
261
261
next spec unless parent_spec
262
-
263
262
next spec if check_precedence . call ( spec , parent_spec ) == :self
264
263
265
264
dependency_changes ||= spec != parent_spec
Original file line number Diff line number Diff line change @@ -57,11 +57,27 @@ def parser(lockfile_name)
57
57
end
58
58
59
59
def specs ( lockfile_name )
60
- @specs [ lockfile_name ] ||= parser ( lockfile_name ) . specs . to_h do |spec |
61
- [ [ spec . name , spec . platform ] , spec ]
60
+ @specs [ lockfile_name ] ||= begin
61
+ specs = { }
62
+ parser ( lockfile_name ) . specs . each do |spec |
63
+ ( specs [ spec . name ] ||= { } ) [ spec . platform ] = spec
64
+ end
65
+ specs
62
66
end
63
67
end
64
68
69
+ # sometimes a gem changes platforms with a new version, such as from aarch64-linux
70
+ # to aarch64-linux-gnu. we need to still sync it
71
+ def find_matching_spec ( specs , spec )
72
+ specs = self . specs ( specs ) unless specs . is_a? ( Hash )
73
+ platform_specs = specs [ spec . name ]
74
+ return unless platform_specs
75
+
76
+ parent_spec = platform_specs [ spec . platform ]
77
+ parent_spec ||= platform_specs . find { |platform , _ | platform =~ spec . platform } &.last
78
+ parent_spec || platform_specs . find { |platform , _ | platform == "ruby" } &.last
79
+ end
80
+
65
81
# @param lockfile_name [Pathname]
66
82
# @return [Hash<String, Set<String>>] hash of gem name to set of gem names that depend on it
67
83
def reverse_dependencies ( lockfile_name )
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ def deep_check(lockfile_definition)
120
120
121
121
# check for conflicting requirements (and build list of pins, in the same loop)
122
122
parser . specs . each do |spec |
123
- parent_spec = @cache . specs ( parent_lockfile_name ) [ [ spec . name , spec . platform ] ]
123
+ parent_spec = @cache . find_matching_spec ( parent_lockfile_name , spec )
124
124
125
125
if lockfile_definition [ :enforce_pinned_additional_dependencies ]
126
126
# look through what this spec depends on, and keep track of all pinned requirements
Original file line number Diff line number Diff line change 863
863
end
864
864
end
865
865
866
+ it "syncs gems whose platforms changed slightly" do
867
+ if RUBY_VERSION < "3.0"
868
+ skip "The test case that triggers this requires Ruby 3.0+; " \
869
+ "just rely on this test running on other ruby versions"
870
+ end
871
+
872
+ with_gemfile ( <<~RUBY ) do
873
+ gem "sqlite3", "~> 1.7"
874
+
875
+ lockfile("all") {}
876
+ RUBY
877
+ invoke_bundler ( "install" )
878
+
879
+ write_gemfile ( <<~RUBY )
880
+ gem "sqlite3"
881
+
882
+ lockfile("all") {}
883
+ RUBY
884
+ invoke_bundler ( "install" )
885
+
886
+ expect ( invoke_bundler ( "info sqlite3" ) ) . to include ( "1.7.3" )
887
+ expect ( invoke_bundler ( "info sqlite3" , env : { "BUNDLE_LOCKFILE" => "all" } ) ) . to include ( "1.7.3" )
888
+
889
+ invoke_bundler ( "update sqlite3" )
890
+ expect ( invoke_bundler ( "info sqlite3" ) ) . not_to include ( "1.7.3" )
891
+ expect ( invoke_bundler ( "info sqlite3" , env : { "BUNDLE_LOCKFILE" => "all" } ) ) . not_to include ( "1.7.3" )
892
+ end
893
+ end
894
+
866
895
it "syncs ruby version" do
867
896
with_gemfile ( <<~RUBY ) do
868
897
gem "concurrent-ruby", "1.2.2"
You can’t perform that action at this time.
0 commit comments