Skip to content

Commit 738d2db

Browse files
hsbtclaude
andcommitted
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. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ba5c7cc commit 738d2db

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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)