Backspace and arrow keys aren't working in IRB(Git Bash console) on windows machine

十年热恋 提交于 2019-11-29 10:40:16

问题


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.


回答1:


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

irb --noreadline



回答2:


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




回答3:


You can also disable readline in ~/.irbrc

IRB.conf[:USE_READLINE] = false



回答4:


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



回答5:


Install the rb-readline gem.

gem install rb-readline



回答6:


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]
~$ 


来源:https://stackoverflow.com/questions/5660209/backspace-and-arrow-keys-arent-working-in-irbgit-bash-console-on-windows-mach

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!