ruby-changes:73002
From: David <ko1@a...>
Date: Sun, 21 Aug 2022 17:53:53 +0900 (JST)
Subject: [ruby-changes:73002] b87ddd7538 (master): [rubygems/rubygems] Fix `bundle platform` crash when there's a lockfile with no Ruby locked
https://git.ruby-lang.org/ruby.git/commit/?id=b87ddd7538 From b87ddd7538220e9782274281356fd55bfd29078b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Fri, 19 Aug 2022 20:35:26 +0200 Subject: [rubygems/rubygems] Fix `bundle platform` crash when there's a lockfile with no Ruby locked https://github.com/rubygems/rubygems/commit/49fc54e87d --- lib/bundler/cli/platform.rb | 2 +- spec/bundler/commands/platform_spec.rb | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/bundler/cli/platform.rb b/lib/bundler/cli/platform.rb index 16d4e0145a..73da8cf80e 100644 --- a/lib/bundler/cli/platform.rb +++ b/lib/bundler/cli/platform.rb @@ -9,7 +9,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/platform.rb#L9 def run platforms, ruby_version = Bundler.ui.silence do - locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version.gsub(/p\d+\Z/, "") + locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "") gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string [Bundler.definition.platforms.map {|p| "* #{p}" }, locked_ruby_version || gemfile_ruby_version] diff --git a/spec/bundler/commands/platform_spec.rb b/spec/bundler/commands/platform_spec.rb index 0b964eac8c..4e8e3946fe 100644 --- a/spec/bundler/commands/platform_spec.rb +++ b/spec/bundler/commands/platform_spec.rb @@ -234,6 +234,29 @@ G https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/platform_spec.rb#L234 expect(out).to eq("ruby 1.0.0") end + it "handles when there is a lockfile with no requirement" do + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + G + + lockfile <<-L + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + + PLATFORMS + ruby + + DEPENDENCIES + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "platform --ruby" + expect(out).to eq("No ruby version specified") + end + it "handles when there is a requirement in the gemfile" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/