Bug #19093
closedgem uninstall, when prompting for gem selection it does not handle CTRL+D
Description
Scenario: calling gem uninstall some_gem
and there is more than 1 version of that gem installed
A list of the n versions of the gem is displayed and a prompt is waiting for a number of the item to uninstall.
When using ctrl+d on the prompt (I'm used to use ctrl+c/ctrl+d to interrupt CLI commands) an exception is raised :
gem uninstall activesupport
Select gem to uninstall:
1. activesupport-6.0.6
2. activesupport-7.0.4
3. All versions
> ERROR: While executing gem ... (NoMethodError)
undefined method `>=' for nil:NilClass
elsif index >= 0 && index < list.size
^^
Ctrl+c is handled correctly but for ctrl+d looks like nil
is returned from #choose_from_list in rubygems/user_interaction.rb and then in Gem::Uninstaller class #uninstall in rubygems/uninstaller.rb that nil is not handled at all:
_, index = choose_from_list "Select gem to uninstall:", gem_names
if index == list.size
remove_all list
elsif index >= 0 && index < list.size
uninstall_gem list[index]
else
say "Error: must enter a number [1-#{list.size + 1}]"
end
I would expect the command to exit silently or maybe exit with that "Error: must enter a number" message but not with an ugly nil error.
Maybe this scenario could be handled more gracefully by the tool?
Updated by retro (Josef Šimánek) about 2 years ago
please follow https://bugs.ruby-lang.org/issues/19092#note-1
Updated by hsbt (Hiroshi SHIBATA) about 2 years ago
- Status changed from Open to Third Party's Issue