Skip to content

Commit e42f1aa

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Fix truffleruby failing to install sorbet-static when there's no lockfile
The generic Ruby platform was getting unconditionally added in truffleruby, preventing resolution in situations where there's no generic ruby version (sorbet-static). Instead, the generic platform should be considered per dependency, not globally. ruby/rubygems@a96afc5351
1 parent 15e9dc1 commit e42f1aa

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

lib/bundler/definition.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,6 @@ def reresolve_without(incomplete_specs)
740740
def start_resolution
741741
local_platform_needed_for_resolvability = @most_specific_non_local_locked_platform && !@platforms.include?(Bundler.local_platform)
742742
@platforms << Bundler.local_platform if local_platform_needed_for_resolvability
743-
add_platform(Gem::Platform::RUBY) if RUBY_ENGINE == "truffleruby"
744743

745744
result = SpecSet.new(resolver.start)
746745

lib/bundler/resolver/package.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def initialize(name, platforms, locked_specs:, unlock:, prerelease: false, prefe
2121
@locked_version = locked_specs.version_for(name)
2222
@unlock = unlock
2323
@dependency = dependency || Dependency.new(name, @locked_version)
24+
@platforms |= [Gem::Platform::RUBY] if @dependency.default_force_ruby_platform
2425
@top_level = !dependency.nil?
2526
@prerelease = @dependency.prerelease? || @locked_version&.prerelease? || prerelease ? :consider_first : :ignore
2627
@prefer_local = prefer_local

spec/bundler/commands/lock_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,6 @@
22372237
nokogiri (1.14.2-x86_64-linux)
22382238
22392239
PLATFORMS
2240-
ruby
22412240
x86_64-linux
22422241
22432242
DEPENDENCIES

spec/bundler/install/gemfile/specific_platform_spec.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,23 @@
392392
end
393393
end
394394

395-
it "installs sorbet-static, which does not provide a pure ruby variant, just fine", :truffleruby do
395+
it "installs sorbet-static, which does not provide a pure ruby variant, in absence of a lockfile, just fine", :truffleruby do
396+
skip "does not apply to Windows" if Gem.win_platform?
397+
398+
build_repo2 do
399+
build_gem("sorbet-static", "0.5.6403") {|s| s.platform = Bundler.local_platform }
400+
end
401+
402+
gemfile <<~G
403+
source "https://gem.repo2"
404+
405+
gem "sorbet-static", "0.5.6403"
406+
G
407+
408+
bundle "install --verbose"
409+
end
410+
411+
it "installs sorbet-static, which does not provide a pure ruby variant, in presence of a lockfile, just fine", :truffleruby do
396412
skip "does not apply to Windows" if Gem.win_platform?
397413

398414
build_repo2 do

0 commit comments

Comments
 (0)