Why does Rails console say "cannot load such file -- readline"?

rails-console, ruby, ruby-on-rails-3.2

Solution

You need to have the readline libraries installed when you compile Ruby.

If you are on CentOS/Redhat/Fedora Linux, install the package using:

sudo yum install readline-devel

Or, on Ubuntu, use:

sudo apt-get install libreadline6 libreadline6-dev

and then recompile Ruby.

Problem

I am new to Ruby on Rails, and am using RVM to manage Ruby versions. My laptop has Ruby1.8.7 installed, but my project is using RVM, Ruby1.9.3 and Rails 3.2.11. I can't run `rails c` or `rails console` without it giving me the following error: ``` /home/phil/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError) from /home/phil/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>' from /home/phil/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands/console.rb:3:in `require' from /home/phil/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands/console.rb:3:in `<top (required)>' from /home/phil/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands.rb:38:in `require' from /home/phil/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands.rb:38:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' ```

Original source