no such file to load — readline (LoadError) – Rails 3.0.3 console – rvm

Problem

When you try to run the console rails c in a new Rails 3.0.3 application, and when you use rvm, you get the following error:

no such file to load -- readline (LoadError)

Solution

It’s quite like likely that the readline libraries are missing from your installation. To find out which ones go to the directory that the error is indicating (ie):

cd ~/.rvm/rubies/ruby-1.8.7-p299

and then to the following:

cd ext/readline

then run the following:

ruby extconf.rb

If you get something like:
checking for readline/readline.h... no
checking for editline/readline.h... no

then you are probably missing the neccessary header files for readline.
so install them in your system (ie in Mandriva):

sudo urpmi readline-dev,

In Debian you will need to install libreadline5-dev and maybe libncurses5-dev (apt-get install).

When the package is installed successfully run the following again:

ruby extconf.rb
make
sudo make install

You should now be able to go back to your project and run rails c with no errors.