Skip to content

Commit 63600d7

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Fix lockfile platforms inconveniently added on JRuby
When working with our repository on JRuby locally, I get the following changes when running `bin/rake setup` in all of our lockfiles ```diff diff --git a/tool/bundler/dev_gems.rb.lock b/tool/bundler/dev_gems.rb.lock index https://github.com/rubygems/rubygems/commit/362bf25690d..https://github.com/rubygems/rubygems/commit/74550b2a408 100644 --- a/tool/bundler/dev_gems.rb.lock +++ b/tool/bundler/dev_gems.rb.lock @@ -66,6 +66,7 @@ PLATFORMS java ruby universal-java + universal-java-22 x64-mingw-ucrt x86-linux x86_64-darwin ``` This is inconvenient, so I applied the same strategy we already use on non JRuby implementations to not add the current platform to the lockfile if a less specific platform is already there. ruby/rubygems@812b9cd1e8
1 parent 8619520 commit 63600d7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/bundler/definition.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def validate_ruby!
490490
end
491491

492492
def validate_platforms!
493-
return if current_platform_locked?
493+
return if current_platform_locked? || @platforms.include?(Gem::Platform::RUBY)
494494

495495
raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \
496496
"but your local platform is #{local_platform}. " \
@@ -731,17 +731,17 @@ def reresolve_without(incomplete_specs)
731731
end
732732

733733
def start_resolution
734-
local_platform_needed_for_resolvability = @most_specific_non_local_locked_ruby_platform && !@platforms.include?(local_platform)
734+
local_platform_needed_for_resolvability = @most_specific_non_local_locked_platform && !@platforms.include?(local_platform)
735735
@platforms << local_platform if local_platform_needed_for_resolvability
736736
add_platform(Gem::Platform::RUBY) if RUBY_ENGINE == "truffleruby"
737737

738738
result = SpecSet.new(resolver.start)
739739

740740
@resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version
741741

742-
if @most_specific_non_local_locked_ruby_platform
743-
if spec_set_incomplete_for_platform?(result, @most_specific_non_local_locked_ruby_platform)
744-
@platforms.delete(@most_specific_non_local_locked_ruby_platform)
742+
if @most_specific_non_local_locked_platform
743+
if spec_set_incomplete_for_platform?(result, @most_specific_non_local_locked_platform)
744+
@platforms.delete(@most_specific_non_local_locked_platform)
745745
elsif local_platform_needed_for_resolvability
746746
@platforms.delete(local_platform)
747747
end
@@ -758,23 +758,23 @@ def precompute_source_requirements_for_indirect_dependencies?
758758

759759
def current_platform_locked?
760760
@platforms.any? do |bundle_platform|
761-
MatchPlatform.platforms_match?(bundle_platform, local_platform)
761+
generic_local_platform == bundle_platform || local_platform === bundle_platform
762762
end
763763
end
764764

765765
def add_current_platform
766766
return if @platforms.include?(local_platform)
767767

768-
@most_specific_non_local_locked_ruby_platform = find_most_specific_locked_ruby_platform
769-
return if @most_specific_non_local_locked_ruby_platform
768+
@most_specific_non_local_locked_platform = find_most_specific_locked_platform
769+
return if @most_specific_non_local_locked_platform
770770

771771
@new_platforms << local_platform
772772
@platforms << local_platform
773773
true
774774
end
775775

776-
def find_most_specific_locked_ruby_platform
777-
return unless generic_local_platform_is_ruby? && current_platform_locked?
776+
def find_most_specific_locked_platform
777+
return unless current_platform_locked?
778778

779779
@most_specific_locked_platform
780780
end

0 commit comments

Comments
 (0)