退格键和箭头键在 Windows 计算机上的 IRB(Git Bash 控制台)中不起作用

发布于 2024-11-01 05:18:31 字数 166 浏览 1 评论 0原文

我刚刚在 Windows 机器上安装了 ruby​​ 1.9.2,退格键或任何其他箭头键不起作用。仅当我在 Git Bash 控制台上打开 IRB 时才会发生这种情况。但它在 Windows 控制台上运行良好。有什么帮助吗?

注意:IRB 在使用早期版本的 ruby​​ 的两个控制台上都可以正常工作。

I just installed ruby 1.9.2 on windows machine and Backspace or any other arrow keys don't work. This happens only when I open IRB on Git Bash console. But it works fine on Windows console. Any help on that?

Note: IRB was working fine on both consoles with the earlier versions of ruby.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

素染倾城色 2024-11-08 05:18:31

同样的事情也发生在我身上。使用 --noreadline 运行 irb 解决了我的问题:

irb --noreadline

Same thing happened to me. Running irb with --noreadline solved my problem:

irb --noreadline
献世佛 2024-11-08 05:18:31

看来你在编译 ruby​​ 时没有安装 readline 。所以安装readline,也许也安装readline-devel,然后重新编译ruby。

Seems you didn't have readline installed while compile ruby. So install readline, maybe also readline-devel, then recompile ruby.

梦萦几度 2024-11-08 05:18:31

您还可以在 ~/.irbrc 中禁用 readline

IRB.conf[:USE_READLINE] = false

You can also disable readline in ~/.irbrc

IRB.conf[:USE_READLINE] = false
双手揣兜 2024-11-08 05:18:31

如此处所述 https://groups.google.com/forum/#! topic/rubyinstaller/HgswOz1T-eE,使用以下命令/别名:

alias irb="ruby -S irb"

如果这不起作用,请改用 pry:

gem install pry

As documented here https://groups.google.com/forum/#!topic/rubyinstaller/HgswOz1T-eE, use the below command/alias:

alias irb="ruby -S irb"

If that doesn't work, use pry instead:

gem install pry
如痴如狂 2024-11-08 05:18:31

安装 rb-readline gem。

gem install rb-readline

Install the rb-readline gem.

gem install rb-readline
给我一枪 2024-11-08 05:18:31

简短的回答我必须进行brew升级,(根据我采访过的一位Ruby专家的说法,情况显然是“主干中有一个新的默认gem,Reline,这是一个readline后备。”)。然后 irb 中的新窗口和箭头键就起作用了。然后 sudo gem install pry,新窗口,pry 工作了。 ruby --version 下降到 2.3,我必须执行brew install ruby​​,它说已经安装了ruby 2.6,并且要执行brew reinstall ruby​​,并且它说要更新路径,我这样做了,然后就好了。安装红宝石2.6。编辑-现在 Rails 坏了..我会进一步更新。

更详细的答案。

我遇到了 ruby​​ irb 箭头键不起作用的问题,

~/blah$ irb
irb(main):001:0> ^[[A^[[D^[[B^[[C

我在 osx 上,并且认为几个月前我没有遇到过这个问题

,并且在启动 pry 时也遇到了错误,pry;它说“原因:找不到图像 - /usr/local/Cellar/ruby/2.5.0/lib/ruby/2.5.0/x86_64-darwin16/readline.bundle”

我尝试了 brew link readline --force 它没有帮助,我尝试了 irb --noreadline 它没有帮助

但是对我有用的是来自 ruby​​ 专家的 - brew升级

根据我采访过的一位 ruby​​ 专家的说法,情况是“主干中有一个新的默认 gem,Reline,这是一个 readline 后备。”

然后我启动了一个新的终端窗口,$irb 使用箭头键工作。

然后我执行了 sudo gem install pry ,打开了一个新的终端窗口,并且 pry 工作了。

Ruby 回落到 2.3,而实际上应该是 2.6,我以为是 2.6

所以我执行了 brew install ruby​​,它说 ruby​​ 2.6 已经安装,并建议 brew 重新安装 ruby​​ >。所以我做了 brew reinstall ruby​​ 。打开一个新的终端窗口。当时还是2.3。但它建议将 export PATH="/usr/local/opt/ruby/bin:$PATH" 添加到 .bash_profile (osx 上自动运行的文件)。我这样做是行不通的,但是在每个终端会话开始时手动执行 PATH="/usr/local/opt/ruby/bin:$PATH" 是有效的。

编辑-现在 Rails 坏了,我会进一步更新。

当我更新路径后运行gem时,我让gem开始工作。

这个解决方案并不理想,因为它提供了两个版本的ruby,因此当然也提供了两个版本的gem

Last login: Fri Aug  9 16:02:48 on ttys001
have run /Users/apple/.bash_profile
~$ cd /usr/local/opt/ruby/bin
/usr/local/opt/ruby/bin$ ls
bundle  bundler erb gem irb rake    rdoc    ri  ruby
/usr/local/opt/ruby/bin$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/rubymac/rubyrailshelperscripts:/opt/X11/bin:/Users/apple/.vimpkg/bin:/usr/local/opt/fzf/bin
/usr/local/opt/ruby/bin$ which gem
/usr/bin/gem
/usr/local/opt/ruby/bin$ cd ~/
~$ /usr/local/opt/ruby/bin/ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin16]
~$ /usr/bin/ru
ruby      runocc.d  
~$ /usr/bin/ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin16]
~$ 

Brief answer I had to do brew upgrade,(Apparently the situation, according to a ruby expert I spoke to, is that "There's a new default gem in trunk, Reline, that's a readline fallback.") . Then a new window and arrow keys in irb worked. Then sudo gem install pry, new window, and pry worked. ruby --version fell to 2.3 and I had to do brew install ruby, it said ruby 2.6 already installed and to do brew reinstall ruby, and it said to update the path, I did that and then fine. ruby 2.6 installed. edit- now rails is broken.. i'll update further.

More elaborate answer.

I had this issue of ruby irb arrow keys not working,

~/blah$ irb
irb(main):001:0> ^[[A^[[D^[[B^[[C

I am on osx, and don't think I had this issue some months ago

and also had an error when starting pry, pry<ENTER> it says "Reason: image not found - /usr/local/Cellar/ruby/2.5.0/lib/ruby/2.5.0/x86_64-darwin16/readline.bundle"

I tried brew link readline --force it didn't help, I tried irb --noreadline it didn't help

But what worked for me was this from a ruby expert- brew upgrade

Apparently the situation, according to a ruby expert I spoke to, is that "There's a new default gem in trunk, Reline, that's a readline fallback."

Then I started a new terminal window and $irb worked with arrow keys.

I then did sudo gem install pry , opened a new terminal window, and pry worked.

Ruby fell back to 2.3 when it should really be 2.6 and I thought it was 2.6

So I did brew install ruby, it said ruby 2.6 was already installed, and suggested brew reinstall ruby. so I did brew reinstall ruby . Opened a new terminal window. It was still on 2.3. But it suggested adding export PATH="/usr/local/opt/ruby/bin:$PATH" to .bash_profile (a file on osx that runs automatically). I did that it didn't work, but doing PATH="/usr/local/opt/ruby/bin:$PATH" manually at the start of each terminal session works.

edit- now rails is broken , i'll update further.

I got gem to work when I ran the one after updating the path..

This solution is not ideal as it gives two versions of ruby, and thus of course two versions of gem

Last login: Fri Aug  9 16:02:48 on ttys001
have run /Users/apple/.bash_profile
~$ cd /usr/local/opt/ruby/bin
/usr/local/opt/ruby/bin$ ls
bundle  bundler erb gem irb rake    rdoc    ri  ruby
/usr/local/opt/ruby/bin$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/rubymac/rubyrailshelperscripts:/opt/X11/bin:/Users/apple/.vimpkg/bin:/usr/local/opt/fzf/bin
/usr/local/opt/ruby/bin$ which gem
/usr/bin/gem
/usr/local/opt/ruby/bin$ cd ~/
~$ /usr/local/opt/ruby/bin/ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin16]
~$ /usr/bin/ru
ruby      runocc.d  
~$ /usr/bin/ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin16]
~$ 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文