Skip to content

Commit b59fe8e

Browse files
hsbtclaude
authored andcommitted
[ruby/rubygems] Handle empty result gracefully in gem pristine --only-missing-extensions
When no gems have missing extensions (e.g. on JRuby where missing_extensions? always returns false), display an informational message instead of raising Gem::Exception. ruby/rubygems@738d2dbdf6 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cb75f04 commit b59fe8e

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

lib/rubygems/commands/pristine_command.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ def execute
132132
specs = specs.select {|spec| spec.platform == RUBY_ENGINE || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
133133

134134
if specs.to_a.empty?
135+
if options[:only_missing_extensions]
136+
say "No gems with missing extensions to restore"
137+
return
138+
end
139+
135140
raise Gem::Exception,
136141
"Failed to find gems #{options[:args]} #{options[:version]}"
137142
end

test/rubygems/test_gem_commands_pristine_command.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,13 @@ def test_execute_extensions_only_missing_extensions
248248
end
249249

250250
refute_includes @ui.output, "Restored #{a.full_name}"
251-
assert_includes @ui.output, "Restored #{b.full_name}"
251+
252+
if Gem.java_platform?
253+
refute_includes @ui.output, "Restored #{b.full_name}"
254+
assert_includes @ui.output, "No gems with missing extensions to restore"
255+
else
256+
assert_includes @ui.output, "Restored #{b.full_name}"
257+
end
252258
end
253259

254260
def test_execute_no_extension

0 commit comments

Comments
 (0)