Why does hitting the left arrow in irb give me "^[[D"?
Asked Answered
G

3

14

I'm using Ubuntu Server 10 lucid, ruby 1.9.2-p0. In irb, the left arrow shows ^[[D. Any idea?

Gentille answered 27/12, 2011 at 7:57 Comment(3)
...as opposed to what? At the very least you'll need a readline-aware irb I believe.Carducci
As for "why": Because that's what the raw command sequence looks like rendered as characters when the console does not specifically handle this key (for example by moving the cursor to the left). :)Kandace
@Kandace thanks for explain the details for meGentille
O
14

You need to do:

sudo apt-get install libreadline-dev

and then reinstall ruby and irb.

Obovate answered 27/12, 2011 at 8:32 Comment(1)
Kind of a longshot, but do you have any sources on what causes this? On Ubuntu I had to install this package and recompile ruby to get up arrow to work.Unwatched
B
6

Alternatively, if you are using RVM, just remember to install readline:

rvm pkg install readline
rvm install 1.9.3 --with-readline-dir=$rvm_path/usr

Over the apt package, this has the advantage of giving you the 1.9.3 version, which IMHO is more stable.

Breeder answered 27/12, 2011 at 8:37 Comment(1)
In my case, I just needed to rvm reinstall <ruby version>. No other action needed regarding packages or anything else.Manda
S
0

IRB is installed with Ruby. I had this problem where it worked and then stopped working. I updated Ruby (rvm install ruby-) and it works again.

Sliver answered 1/6, 2018 at 19:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.