Rambling Labs Blog Ramblings on software development

  • Rails 3.1 "rails console" fails with "no such file to load -- readline"

    Yesterday, I was trying to run the rails console command on Ubuntu with ruby 1.9.2 and rails 3.1, without any success. I was getting a no such file to load -- readline error. This kind of error was sort of familiar for me (I had the common no such file to load -- zlib and the not so common no such file to load -- openssl a while ago). So this was probably another package that I was missing.

    Turns out that as I found in a Stack Overflow question, I needed the libreadline-dev, which I didn't have installed. But I also needed to recompile ruby, seriously!?

    This is where rvm comes to the rescue, and why I love so much to have rvm installed :D. You only need to install the rvm package, remove the rubies and reinstall them.
    So I ended up running this set of commands, and if you have this issue, you should run it as well:

    apt-get install libreadline-dev
    rvm pkg install readline
    rvm remove 1.9.2
    rvm install 1.9.2
    rvm --default 1.9.2
    rvm use 1.9.2
    

    And, when I finally ran rails console, it all went well.
    That's it, no more recompiling ruby yourself. Let rvm take care of that.

    Seems like I'm getting more familiar with this whole thing. :)

  • blog comments powered by Disqus