Fix arrow keys in IRB in Ubuntu
Issue
If you’re a rails programmer in Ubuntu, odds are you’re going to encounter some issues while trying to use your arrow keys inside IRB (Interactive Ruby), and this particular problem will also affect script/console.
- Arrow keys don’t work in IRB
- Can’t load script/console
Symptoms
If you try to launch your console, the following errors will appear. As you can tell, we’ve got a library missing – “readline”.
script/console Loading development environment (Rails 2.2.2) /usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError) from /usr/local/lib/ruby/1.8/irb/completion.rb:10 from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `require' from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules' from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `each' from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules' from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup' from /usr/local/lib/ruby/1.8/irb.rb:54:in `start' from /usr/local/bin/irb:13
Fix
Marinate your keyboard with some Dr. Pepper. For best results, use beer. NO! Buy a MAC. NO! I joke . MACS are expensive.
Fix it this way:
- Install the readline library: sudo apt-get install libreadline5 libreadline5-dev
- Compile the library: cd into the “ext/readline” inside your ruby installation. It’s probably under “/usr/local/src”, but you’ll definitely need to figure this one on your own.
- sudo ruby extconf.rb
- sudo make
- sudo make install
- Re-launch IRB and script/console and it should work!



















