Randall
Randall

Reputation: 3044

Perl debugger does not work with arrow keys under Perlbrew

I'd like arrow keys to work for command history in perl debugger. This solution looks good, so since I'm using ubuntu, I tried

sudo aptitude install libterm-readline-gnu-perl

But, I still get the ^[[A and ^[[B echoed back in the perl debugger instead of previous/next commands.

I have found this is specifically an issue within my perlbrew envinronment. If I run /usr/bin/perl -d the arrow keys do work (ie, the install fixed it only for that perl).

How do I get the debugger to work under perlbrew?

As a last-ditch effort, within my perlbrew environment I tried cpanm Term::ReadLine::Gnu but got the error

Could not find neither libtermcap.a, libncurses.a, or libcurses.

I could start installing more libraries, but it feels like I'm missing something else, since it's only a problem affecting Perlbrew.

Upvotes: 2

Views: 513

Answers (2)

Randall
Randall

Reputation: 3044

Installing the packages @melpomene suggests does do the trick.

But I found another solution that does not require the dev packages (and, hence, does not require root). Either of the following CPAN packages can be used on their own:

  • Term::ReadLine::Perl (Perl implementation of Readline libraries)
  • Term::Readline::Zoid (Pure Perl implementation of Readline libraries)

Since Perlbrew is sometimes (often?) used in environments where you don't have root, this is probably a more convenient solution.

Upvotes: 1

melpomene
melpomene

Reputation: 85907

Perl modules installed via your distribution's package system are only available in the perl from your distribution (i.e. /usr/bin/perl). Other perl installations (e.g. those managed by perlbrew) are not affected. That's why other perls don't see Term::ReadLine::Gnu.

Installing Term::ReadLine::Gnu from within the perlbrew environment (e.g. via cpan or cpanm) is the right solution. The error you're getting is probably caused by missing development headers (Term::ReadLine::Gnu is a wrapper around the readline C library, so it needs headers to build). Try installing ncurses-dev (with aptitude), then run cpanm again.

Upvotes: 2

Related Questions