When trying to install ruby 1.9.2 on Ubuntu 10.04 (64-bit), I get the following error after performing the following steps:
- Install Dependencies
- ./configure to create make file
- Make
- Make Install
- Make Clean
- ruby -ropenssl -rzlib -rreadline -e "puts :Hello" (This should output 'hello' if all is well).,
Instead of outputting hello, I get this:
require: no such file to load -- readline`
After searching online, I find this solution: Blockquote
If you’ve compiled Ruby from source, you might get this error when executing script/console:
/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError) One way of fixing this is to compile readline, which is distributed along with the Ruby source:
cd /opt/src/ruby-1.8.5-p2/ext/readline
ruby extconf.rb
make
sudo make install
This totally worked for me. My question is, why didn't ruby compile this to begin with? Did I forget some sort of config option?
2 Answers
The reason Ruby didn't automatically include readline support was most likely because you didn't have libreadline, and its development files, installed on your system. When you run ./configure it does an inventory of your system, and uses that data to create an "optimal" Makefile.
The easiest way to get libreadline, and its development files, is to install the package libreadline-dev.
Many (in fact, most) libraries and programming languages don't compile readline by default (PHP is another example). You need to configure that manually in the configure script or using this method. Just make sure you use the same option whenever you compile Ruby.