[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-core
Subject: [ruby-core:110549] [Ruby master Bug#19093] gem uninstall, when prompting for gem selection it does n
From: retro <noreply () ruby-lang ! org>
Date: 2022-10-30 22:41:43
Message-ID: redmine.journal-99875.20221030224143.52170 () ruby-lang ! org
[Download RAW message or body]
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/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic