How to make readline work in IRB?

Discussion in 'Ruby' started by Randy Kramer, Mar 22, 2006.

  1. Randy Kramer

    Randy Kramer Guest

    I did mention this in another thread, but (I think) think I've learned a
    little more, and decided to start a new thread.

    My problem is that after compiling Ruby 1.8.4 and installing it in place of
    the Mandriva2006 packaged 1.8.2, the irb command line works differently in
    that:

    * there is no command history (and the up and down arrow just show garbage)
    * the left and right arrow just show garbage
    * previously I could paste multiple lines of code to the irb prompt and irb
    automagically made sense of them, putting each on an individual line (with
    leading irb prompt), and working fine. Now I have to paste lines
    individually.

    After a little research and a lucky clue/guess, I believe that the missing
    functionality comes from readline, so I'm trying to make irb use
    readline--and here's what I've tried or think I know:

    * I'm guessing the missing functionality comes from readline
    * there is a way to enable/disable readline in irb (or in ~/.irbrc, which
    didn't exist until I created it)
    * typing conf at the irb prompt shows me the configuration parameters that
    can be set
    * contrary to what it says in the first Programming Ruby book, there is no
    conf.inf_ruby_mode (which may have affected readline--trying to set it gives
    an error)
    * conf.use_readline was set to false--
    * changing it to true did not change the behavior described above
    * stopping and restarting irb showed that a change was not
    persistent--reverted to false
    * creating ~/.irbrc and including the line "IRB.conf[:USE_READLINE] =
    true" made the change persist, but the behavior still did not change
    * just for kicks, without having any idea what I'm doing, I searched
    through the configure file (you know, for the ./configure step) to see if
    there is any reference to readline--there is not.

    So, any hints? Because the behavior existed in the Mandriva2006 packaged Ruby
    1.8.2, and since the behavior on other similar programs seems to make use of
    readline, and I didn't uninstall readline when I uninstalled Ruby 1.8.2, I
    have to believe readline is installed on my machine.

    PS: I wouldn't think that readline is a cli command, but just for kicks I
    typed "readline" at the prompt. It comes back with "bash: readline: command
    not found". Then I grepped ps -el and don't find any evidence of a readline
    process running. Again, I don't have any idea whether it should, I'm just
    trying to confirm readline is installed. Oops, wait--I can check using
    rpmdrake (or drakerpm)...well, son of a gun--rpm -q readline returns:

    [rhk@s14 rhk]$ rpm -q readline
    package readline is not installed

    I guess I'll go install it, then see what happens. Will I have to reinstall
    ruby?

    Well, wait, doing a whatprovides shows:

    [root@s14 /]# rpm -q --whatprovides readline
    libreadline5-5.0-2mdk

    Then, trying to:
    * install libreadline5-5.0-2mdk (with rpmdrake) shows it is not available
    * uninstall libreadline5-5.0-2md shows I could uninstall it

    Both of which imply that it is already installed. Hmm, I probably don't
    understand all I know here, so I think I'll:

    * send this to the list, see if anybody else has some hints
    * while I cogitate a little before trying anything

    Maybe the rpm -q readline was the wrong thing to do, ahh but now trying

    [root@s14 /]# rpm -q libreadline
    package libreadline is not installed

    I get a similar result. Maybe that's part of the problem--I think I'll try to
    uninstall then reinstall libreadline.

    Oops, don't think I want to do that, looks like rpmdrake would want to
    uninstall most of my system because so many things depend on libreadline.

    So, I'll send this and see if anybody has some suggestions.

    Randy Kramer
    Randy Kramer, Mar 22, 2006
    #1
    1. Advertising

  2. Randy Kramer wrote:

    > [root@s14 /]# rpm -q libreadline
    > package libreadline is not installed
    >
    > I get a similar result. Maybe that's part of the problem--I think I'll try to
    > uninstall then reinstall libreadline.


    You may need the devel version of the package, so the readline headers
    are found when you compile ruby.

    --
    vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
    Joel VanderWerf, Mar 22, 2006
    #2
    1. Advertising

  3. Randy Kramer

    Randy Kramer Guest

    On Wednesday 22 March 2006 01:17 pm, Joel VanderWerf wrote:
    > Randy Kramer wrote:
    > > [root@s14 /]# rpm -q libreadline
    > > package libreadline is not installed
    > >
    > > I get a similar result. Maybe that's part of the problem--I think I'll
    > > try to uninstall then reinstall libreadline.

    >
    > You may need the devel version of the package, so the readline headers
    > are found when you compile ruby.


    Joel,

    Thanks! That sounds like a likely possibility, but I'm not very familiar with
    that kind of stuff. Haven't found a package anything like readline-devel or
    similar, nor a readline.h on my system. Posted a question over on the
    Mandriva expert list, I'll see if somebody there can give me some help.

    Randy Kramer
    Randy Kramer, Mar 22, 2006
    #3
  4. Randy Kramer wrote:
    > Thanks! That sounds like a likely possibility, but I'm not very familiar with
    > that kind of stuff. Haven't found a package anything like readline-devel or
    > similar, nor a readline.h on my system. Posted a question over on the
    > Mandriva expert list, I'll see if somebody there can give me some help.


    Also thought I'd just throw in that readline depends on ncurses.
    Whether your packaging system takes care of that or not is unknown, but
    it's good to be aware.

    --Steve
    Stephen Waits, Mar 22, 2006
    #4
  5. --------------000609080000030108030207
    Content-Type: text/plain; charset=ISO-8859-1; format=flowed
    Content-Transfer-Encoding: 7bit

    Randy Kramer wrote:
    > On Wednesday 22 March 2006 01:17 pm, Joel VanderWerf wrote:
    >
    >> Randy Kramer wrote:
    >>
    >>> [root@s14 /]# rpm -q libreadline
    >>> package libreadline is not installed
    >>>
    >>> I get a similar result. Maybe that's part of the problem--I think I'll
    >>> try to uninstall then reinstall libreadline.
    >>>

    >> You may need the devel version of the package, so the readline headers
    >> are found when you compile ruby.
    >>

    >
    > Joel,
    >
    > Thanks! That sounds like a likely possibility, but I'm not very familiar with
    > that kind of stuff. Haven't found a package anything like readline-devel or
    > similar, nor a readline.h on my system. Posted a question over on the
    > Mandriva expert list, I'll see if somebody there can give me some help.
    >
    > Randy Krame


    For LE2005 there are a couple packages: libreadline4-devel and
    libreadline5-devel.
    I bet one of those will help you.

    -Justin

    --------------000609080000030108030207--
    Justin Collins, Mar 22, 2006
    #5
  6. Randy Kramer

    Randy Kramer Guest

    Problem resolved: thanks and a followup question (was Re: How to make readline work in IRB?)

    On Wednesday 22 March 2006 02:37 pm, Justin Collins wrote:
    > > On Wednesday 22 March 2006 01:17 pm, Joel VanderWerf wrote:
    > >> You may need the devel version of the package, so the readline headers
    > >> are found when you compile ruby.

    > For LE2005 there are a couple packages: libreadline4-devel and
    > libreadline5-devel.
    > I bet one of those will help you.


    Thanks to all who replied! I found the libreadline5-devel package, installed
    it, then recompiled and reinstalled ruby 1.8.4 and the irb command line is
    working fine.

    I learned a few things along the way (like some of the wrong ways to search
    for libreadline on rpmfind (neither a search for readline or readline-devel
    will find libreadline)--not sure what I did wrong in my google
    searches--maybe searched for readline-devel which wasn't found because of the
    number in libreadline5-devel).

    I am curious about why I didn't see a message about something not finding
    readline during the first install--maybe it was buried in the tons of warning
    messages I got about signs not matching (and events).

    In the future I'll try to remember to redirect the stderr and stdout to two
    different files, then look at the errors more closely.

    Does anybody here know--should I have seen an error/warning related to the
    missing readline.h headers? During the ./configure or the make step?

    Thanks again!
    Randy Kramer
    Randy Kramer, Mar 23, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gavino
    Replies:
    4
    Views:
    536
    gavino
    Sep 20, 2010
  2. Replies:
    0
    Views:
    119
  3. Sam Stephenson
    Replies:
    1
    Views:
    225
    Andrew Walrond
    Jun 18, 2005
  4. Jean-Michel
    Replies:
    0
    Views:
    359
    Jean-Michel
    Dec 22, 2007
  5. Andrew DeFaria
    Replies:
    1
    Views:
    208
    Ben Morrow
    Jan 30, 2008
Loading...

Share This Page