Skip to content

Commit b87ddd7

Browse files
deivid-rodriguezmatzbot
authored andcommitted
[rubygems/rubygems] Fix bundle platform crash when there's a lockfile with no Ruby locked
ruby/rubygems@49fc54e87d
1 parent f6d4d73 commit b87ddd7

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/bundler/cli/platform.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def initialize(options)
99

1010
def run
1111
platforms, ruby_version = Bundler.ui.silence do
12-
locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version.gsub(/p\d+\Z/, "")
12+
locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
1313
gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
1414
[Bundler.definition.platforms.map {|p| "* #{p}" },
1515
locked_ruby_version || gemfile_ruby_version]

spec/bundler/commands/platform_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,29 @@
234234
expect(out).to eq("ruby 1.0.0")
235235
end
236236

237+
it "handles when there is a lockfile with no requirement" do
238+
gemfile <<-G
239+
source "#{file_uri_for(gem_repo1)}"
240+
G
241+
242+
lockfile <<-L
243+
GEM
244+
remote: #{file_uri_for(gem_repo1)}/
245+
specs:
246+
247+
PLATFORMS
248+
ruby
249+
250+
DEPENDENCIES
251+
252+
BUNDLED WITH
253+
#{Bundler::VERSION}
254+
L
255+
256+
bundle "platform --ruby"
257+
expect(out).to eq("No ruby version specified")
258+
end
259+
237260
it "handles when there is a requirement in the gemfile" do
238261
gemfile <<-G
239262
source "#{file_uri_for(gem_repo1)}"

0 commit comments

Comments
 (0)