Project

General

Profile

Actions

Bug #19093

closed

gem uninstall, when prompting for gem selection it does not handle CTRL+D

Added by megatux (Cristian Molina) over 1 year ago. Updated over 1 year ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
[ruby-core:110547]

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?

Actions #2

Updated by hsbt (Hiroshi SHIBATA) over 1 year ago

  • Status changed from Open to Third Party's Issue
Actions

Also available in: Atom PDF

Like0
Like0Like0