From: "megatux (Cristian Molina)" <noreply@ruby-lang.org>
To: ruby-core@neon.ruby-lang.org
Subject: [ruby-core:110547] [Ruby master Bug#19093] gem uninstall, when prompting for gem selection it does not handle CTRL+D
Date: Sun, 30 Oct 2022 21:35:50 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-19093.20221030213550.52170@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19093.20221030213550.52170@ruby-lang.org
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/
next parent reply other threads:[~2022-10-30 21:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-30 21:35 megatux (Cristian Molina) [this message]
2022-10-30 22:41 ` [ruby-core:110549] [Ruby master Bug#19093] gem uninstall, when prompting for gem selection it does not handle CTRL+D retro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-19093.20221030213550.52170@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
--cc=ruby-core@neon.ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).