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]
~$
irb
script to add it automatically to command line arguments. For others, my script was inC:\Ruby\1.9.3\bin\irb
and I addedARGV << "--noreadline"
just after therequire 'irb'
statement. – Uncloak