ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:110547] [Ruby master Bug#19093] gem uninstall, when prompting for gem selection it does not handle CTRL+D
@ 2022-10-30 21:35 megatux (Cristian Molina)
  2022-10-30 22:41 ` [ruby-core:110549] " retro
  0 siblings, 1 reply; 2+ messages in thread
From: megatux (Cristian Molina) @ 2022-10-30 21:35 UTC (permalink / raw
  To: ruby-core

Issue #19093 has been reported by megatux (Cristian Molina).

----------------------------------------
Bug #19093: gem uninstall, when prompting for gem selection it does not handle CTRL+D
https://bugs.ruby-lang.org/issues/19093

* Author: megatux (Cristian Molina)
* Status: Open
* Priority: Normal
* ruby -v:  3.1.2p20
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
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:

```ruby
      _, 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?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ruby-core:110549] [Ruby master Bug#19093] gem uninstall, when prompting for gem selection it does not handle CTRL+D
  2022-10-30 21:35 [ruby-core:110547] [Ruby master Bug#19093] gem uninstall, when prompting for gem selection it does not handle CTRL+D megatux (Cristian Molina)
@ 2022-10-30 22:41 ` retro
  0 siblings, 0 replies; 2+ messages in thread
From: retro @ 2022-10-30 22:41 UTC (permalink / raw
  To: ruby-core

Issue #19093 has been updated by retro (Josef Šimánek).


please follow https://bugs.ruby-lang.org/issues/19092#note-1

----------------------------------------
Bug #19093: gem uninstall, when prompting for gem selection it does not handle CTRL+D
https://bugs.ruby-lang.org/issues/19093#change-99875

* Author: megatux (Cristian Molina)
* Status: Open
* Priority: Normal
* ruby -v:  3.1.2p20
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
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:

```ruby
      _, 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?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-30 22:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-30 21:35 [ruby-core:110547] [Ruby master Bug#19093] gem uninstall, when prompting for gem selection it does not handle CTRL+D megatux (Cristian Molina)
2022-10-30 22:41 ` [ruby-core:110549] " retro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).