Forum: Ruby How to make readline work in IRB?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Randy K. (Guest)
on 2006-03-22 18:50
(Received via mailing list)
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 K.
Joel VanderWerf (Guest)
on 2006-03-22 20:17
(Received via mailing list)
Randy K. 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.
Randy K. (Guest)
on 2006-03-22 21:29
(Received via mailing list)
On Wednesday 22 March 2006 01:17 pm, Joel VanderWerf wrote:
> Randy K. 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 K.
Stephen W. (Guest)
on 2006-03-22 21:37
(Received via mailing list)
Randy K. 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
Justin C. (Guest)
on 2006-03-22 21:37
(Received via mailing list)
Randy K. wrote:
>> You may need the devel version of the package, so the readline headers
> Randy Krame
For LE2005 there are a couple packages: libreadline4-devel and
libreadline5-devel.
I bet one of those will help you.

-Justin
Randy K. (Guest)
on 2006-03-23 17:43
(Received via mailing list)
On Wednesday 22 March 2006 02:37 pm, Justin C. 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 K.
This topic is locked and can not be replied to.