Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

SOLVED: How to install Term::ReadLine::Gnu in perlbrew ... only once?

by haj (Chaplain)
on Nov 06, 2019 at 18:10 UTC ( #11108391=perlquestion: print w/replies, xml ) Need Help??

haj has asked for the wisdom of the Perl Monks concerning the following question:

Edited to add: The rest of this article is now mostly interesting if someone happens to stumble over the same symptoms, since the solution was indeed a messed-up setup of my system. It turned out that I had an activation of local::lib in my .bashrc, probably copied from an outdated backup of the previous desktop. After deleting the line eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)" from .bashrc everything works as it should. There is no problem with having XS libraries for multiple versions of Perl with perlbrew. Binaries from different verions of XS components end up in different directories, and if they are wrappers for system libraries like libreadline, then all of them resolve quite fine against same the system library.

Hi fellow monks,

One of the routine modules I'm installing in Perl is Term::ReadLine::Gnu, because without it I can't use arrow-up to browse through the history in the Perl debugger. I am on Debian Buster and I have libterm-readline-gnu-perl installed. Fine so far.

But I'm also using perlbrew, so I want to have the same module in my perlbrew environments. I have cpamn set up so it installs everything under ~/perl5, which works quite well, with the notable exception of Term::ReadLine::Gnu.

I couldn't just cpanm Term::ReadLine::Gnu because I need to have the readline headers. This did not surprise me too much since that happens with all Perl modules which are just wrappers around some system libs. So, I installed the Debian package libreadline-dev, and voila, cpanm Term::ReadLine::Gnu installs quite fine and works.

However, as soon as I switch the perl version (in that case from 5.30.0 to 5.22.1) to and enter the debugger, I get:

Loading DB routines from perl5db.pl version 1.49 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. main::(-e:1): 1 Cannot do `initialize' in Term::ReadLine::Gnu at /home/haj/perl5/perlb +rew/perls/perl-5.22.1/lib/5.22.1/perl5db.pl line 6840. at /home/haj/perl5/lib/perl5/x86_64-linux/Term/ReadLine/Gnu.pm line 8 +56. Term::ReadLine::Gnu::AU::AUTOLOAD(Term::ReadLine=HASH(0x5587e4 +eb29c0)) called at /home/haj/perl5/lib/perl5/x86_64-linux/Term/ReadLi +ne/Gnu.pm line 297 Term::ReadLine::Gnu::new("Term::ReadLine", "perldb", GLOB(0x55 +87e44ddd30), GLOB(0x5587e45cd218)) called at /home/haj/perl5/perlbrew +/perls/perl-5.22.1/lib/5.22.1/perl5db.pl line 6840 DB::setterm() called at /home/haj/perl5/perlbrew/perls/perl-5. +22.1/lib/5.22.1/perl5db.pl line 1832 DB::_DB__read_next_cmd(undef) called at /home/haj/perl5/perlbr +ew/perls/perl-5.22.1/lib/5.22.1/perl5db.pl line 2761 DB::DB called at -e line 1 Cannot do `initialize' in Term::ReadLine::Gnu at /home/haj/perl5/perlb +rew/perls/perl-5.22.1/lib/5.22.1/perl5db.pl line 6840. END failed--call queue aborted at -e line 8671. at -e line 8671.

However, under the 5.22.1, I can also install cpanm Term::ReadLine::Gnu, and from that time on, it works. Until I switch back to 5.30.1, where I get the same error.

Is there a way around this? I'd rather not re-install Term::ReadLine::Gnu every time I switch the Perl version...

  • Comment on SOLVED: How to install Term::ReadLine::Gnu in perlbrew ... only once?
  • Download Code

Replies are listed 'Best First'.
Re: How to install Term::ReadLine::Gnu in perlbrew ... only once?
by Fletch (Chancellor) on Nov 06, 2019 at 18:30 UTC

    Were it pure perl, it'd work. Unfortunately for modules with XS components you're probably not going to have any luck unless you stay within the same major revision (and then I don't know offhand if it's a written guarantee to maintain binary compatibility; I'm sure someone here may be able to quote chapter and verse one way or the other). At best you're likely to have something that just won't load like you're seeing; at worst you might get something which will load but then will randomly SEGV because the "shape" of some perl data structure has changed underneath it and it goes chasing what it thinks should be the foo pointer but is really the lower half of a long double now.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      perlbrew exec perl cpanm Term::ReadLine::Gnu
Re: How to install Term::ReadLine::Gnu in perlbrew ... only once?
by LanX (Archbishop) on Nov 06, 2019 at 18:35 UTC
    I used to work with several pure-Perl backend alternatives which worked really well.

    But I don't remember anymore which one was the best... (Update: probably Term::ReadLine::Zoid)

    Can I extend your question?

    What's the best module on Windows?

    I also enjoy having a cmd-history between sessions ...

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      I've tried Term::ReadLine::Zoid and also Term::ReadLine::Perl. The Zoid variant installs without a hitch but isn't picked up by the Perl debugger (though perldoc perldebug suggests otherwise). Arrows are just escape sequences. The Perl variant fails to install with ReadKey.c: loadable library and perl binaries are mismatched (got handshake key 0xc180000, needed 0xd700000). Oops?

      But then: I was pretty sure that I didn't have that problem under Debian Jessie, for none of the gazillions of XS modules I tend to collect over time. And indeed: I could fire up an old image of mine, and all is fine from Perl 5.10.1 to Perl 5.30.0.

      However, my usual suspect right now isn't the Debian version, but rather some perlbrew, or maybe perlbrew plus cpanm issue on my current system. These are the symptoms as given by the debugger on p \%INC:

      On the old desktop, for Perl 5.10:

      'Term/ReadLine.pm' => '/home/haj/perl5/perlbrew/perls/perl-5.10.1/lib +/5.10.1/Term/ReadLine.pm' 'Term/ReadLine/Gnu.pm' => '/home/haj/perl5/perlbrew/perls/perl-5.10.1 +/lib/site_perl/5.10.1/x86_64-linux/Term/ReadLine/Gnu.pm' 'Term/ReadLine/Gnu/XS.pm' => '/home/haj/perl5/perlbrew/perls/perl-5.1 +0.1/lib/site_perl/5.10.1/x86_64-linux/Term/ReadLine/Gnu/XS.pm

      On the new desktop:

      'Term/ReadLine.pm' => '/home/haj/perl5/perlbrew/perls/perl-5.30.0/lib +/5.30.0/Term/ReadLine.pm' 'Term/ReadLine/Gnu.pm' => '/home/haj/perl5/lib/perl5/x86_64-linux/Ter +m/ReadLine/Gnu.pm' 'Term/ReadLine/Gnu/XS.pm' => '/home/haj/perl5/lib/perl5/x86_64-linux/ +Term/ReadLine/Gnu/XS.pm'

      So, while the old desktop kept the Perl version in the path and therefore each of the Gnu libraries separate, the new desktop doesn't - and therefore the installation processes clobber each other's files. Maybe I goofed up when installing perlbrew and should start over again...

      I've no concrete info about your extended question but only vague memories that the command history in the debugger just worked... after setting TERM=dumb, most probably with Term::ReadLine::Gnu because I think that my habit to install that module dates back to my Windows times.

        Thanks I'll look into it and give feedback till weekend.

        Zoid needs (environment) variables to be set to get plugged in by the debugger. I suppose you're aware.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re: SOLVED: How to install Term::ReadLine::Gnu in perlbrew ... only once?
by Aldebaran (Chaplain) on Nov 09, 2019 at 07:01 UTC
    After deleting the line eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)" from .bashrc everything works as it should.

    I just did the same thing whilst getting termux bootstrapped:

    tar zvxf local-lib-2.000011.tar.gz cd local-lib-2.000011 perl Makefile.PL --bootstrap pkg install make make test && make install echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >>~/.bashrc

    After a dozen attempts, I installed a fresh .bashrc and finally failed to fail....

Re: SOLVED: How to install Term::ReadLine::Gnu in perlbrew ... only once?
by maggotbrain (Monk) on Nov 07, 2019 at 03:56 UTC
    I just ran into a similar problem with perlbrew and Term::ReadLine:Perl this week on an Ubuntu 19.04 box.

    I had Term::ReadLine::Perl installed via cpan. This would break with a similar error as yours when I went into the debugger for any version installed with perlbrew.

    After numerous attempts to install Term::ReadLine::Perl (or ::Gnu) in the perlbrew environments, I was finally able to resolve the issue. I needed to remove Term::ReadLine::Perl from cpan and then install my system's library. In my case, I installed libterm-readline-perl-perl

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11108391]
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2019-11-18 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (92 votes). Check out past polls.

    Notices?