e x p r e s s i c a

ruby on rails, business and technicalities

No public Twitter messages.

  • RSS
  • Facebook
  • Twitter
  • Linkedin

It was ruining all my mood and concentration when i was trying some sample ruby code in irb and again and again i had to retype the things because the arrow keys were not working there. I searched the problem on net and found that i need to have readline library on my linux and in ruby as well. Now the point is readline should be available on the linux before you compile ruby so as you can give the readline option while compiling ruby. BUT we have ruby already installed !! Now What ?

Now, first you will need to install system based readline libraries as

  sudo apt-get install libreadline5 libreadline5-dev

If you are not able to install linux based readline with the above method the refer this for more details.

Now you will need to compile the ruby based readline interface to let you readline library available in irb.
Do it by this…

  cd /usr/local/src/ruby-1.8.6/ext/readline
  sudo ruby extconf.rb
  sudo make
  sudo make install

thats it, all done!!
Try your tips on arrow keys in irb, it should work now.

11 Responses so far.

  1. Jeet says:


    Hey You are a ruby people and you are using php for your ruby site if we ruby people will not promote Ruby How will ruby SPREAD ?

  2. sur says:

    Hey Jeet,

    I hope i will get time to switch on to Mephisto or else soon !

  3. Makuchaku says:


    Nice blog!

    Try http://www.rubyinside.com/wirble-tab-completion-and-syntax-coloring-for-irb-336.html for more cool stuff on IRB – output coloring and tab completion

    PS: I read that you are a .NET convert – dude, you’ve converted pretty well :)

  4. sur says:

    Thanks Maku!!

    thats really useful gem for irb.

  5. KevinC says:

    Thanks for this post ! It saved me.

    Especially this line:
    sudo apt-get install libreadline5 libreadline5-dev

  6. [...] Installing Ruby 1.8 and 1.9 Side by Side Multiple Versions of Ruby on Ubuntu #3 How to make arrow keys working in irb in Linux/Ubuntu [...]

  7. zipizap123 says:

    I use RubyVersionManager (rvm) to download/update severall ruby versions in paralell, and I had the same problem with irb keys in all the ruby versions installed with rvm.

    To fix the irb of one of the ruby versions installed – in this case the ruby-1.9.1-p378 – I’ve done a slightly changed version of the commands posted above:

    sudo apt-get install libreadline5 libreadline5-dev
    cd ~/.rvm/src/ruby-1.9.1-p378/ext/readline/
    ruby extconf.rb
    make install

    I believe that if you want to fix the irb of another of the ruby versions installed, you will have to do the same cd + ruby extconf.rb + make install in the corresponding directory of that specific ruby version.

    PS: The rvm is the best way I found to download the latest ruby version available and still keep an older ruby version side-by-side without conflicts (it even keeps seperate gems versions apart, so they don’t conflict with each other – in short, you can have several rubys/gems versions installed and select which of them to use when you want, very easy to use)

  8. [...] As usual, I had to go in search for the cause and solution. After bit of googling I fell on a right blogpost. The problem/fix explained was exactly same and that fix worked for [...]

  9. Aby says:

    Hi, sorry for restoring old post but do you know how to fix this in windows (actually in portable git) ?

  10. Preetam says:

    I couldn’t install v5 (libreadline5) as this may have become obsolete. Tried with v6 (libreadline6) and that was successful. Thanks for this post mate. Cheers.

  11. Pat Guano says:

    Towards the end of 2011 and with Ruby 1.9.3, those hint are still valid
    and helful.