I have been seeing the following, for the past 18 months, every time I use the cpan utility:

$ cpan Terminal does not support AddHistory. To fix that, maybe try> install Term::ReadLine::Perl cpan shell -- CPAN exploration and modules installation (v2.28) Enter 'h' for help. cpan[1]>

I looked into that briefly (and unsuccessfully) several times; in general, whatever I wanted to install via cpan was more important than AddHistory, which I only use infrequently anyway, so it ended up on my TODO list.

I tried with the suggested module, Term::ReadLine::Perl, as well as a variety of others including: Term::ReadLine::Perl5, Term::ReadLine::Gnu, and Term::ReadLine::Tiny. These all failed, the most common problem being the process hanging when the Term::ReadKey dependency was being installed. Actually, installation of Term::ReadLine::Tiny worked fine but it didn't provide AddHistory.

I spent some hours this morning looking into this and eventually came up with a solution. My basic Perl setup is: Win10 - Cygwin - Perlbrew - Perl 5.32.0. If you're experiencing the same problem, this solution may work for you: I can't make any guarantees as I don't have other systems on which to test this.

The only thing that worked was a completely manual installation.

Download https://cpan.metacpan.org/authors/id/J/JS/JSTOWE/TermReadKey-2.38.tar.gz then run the familiar incantation:

$ tar zxvf TermReadKey-2.38.tar.gz $ cd TermReadKey-2.38 $ perl Makefile.PL $ make $ make test $ make install

Download https://cpan.metacpan.org/authors/id/H/HA/HAYASHI/Term-ReadLine-Gnu-1.37.tar.gz then a very similar incantation:

$ tar zxvf Term-ReadLine-Gnu-1.37.tar.gz $ cd Term-ReadLine-Gnu-1.37 $ perl Makefile.PL $ make $ make test $ make install

Now I get:

$ cpan cpan shell -- CPAN exploration and modules installation (v2.28) Enter 'h' for help. cpan[1]>

and moving through the command history and editing is now possible.

If you were experiencing similar problems with a different setup to me — and found this worked as is, worked after some modification, or failed abysmally — please leave a note for the next reader.

— Ken

Replies are listed 'Best First'.
Re: cpan: Terminal does not support AddHistory.
by Don Coyote (Hermit) on Jan 05, 2021 at 05:29 UTC

    Hello kcott

    Using perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x86-multi-thread, and running debugger from cmd with the -d switch, a warning about SetConsoleMode failed at line 277 Term::ReadKey.pm is produced.

    I looked into it a little bit and found the issue to be literal backticks being used in Term::ReadKey. That is to say there was no fail message when I (iirc) replaced with perl function system call. As described in Mastering Perl, using the first element of array code sub form.

    I thought I had posted a SoPW about that, though cannot find any related threads; may have been chatterbox. I did not follow up with a bug report, due to only reproducing on an earlier than current version.

    I recently acquired perl 5, version 30, subversion 1 (v5.30.1) built for MSWin32-x86-multi-thread and can confirm there are no warnings produced when running debugger via switch.

    However, Corelist doesn't appear to mention Term::Readkey as being released with core, and as such is explainably not shipped with the vendor version. Term::ReadLine has been included with Core since at most v5.2, and was updated as recently as v5.27.4

      G'day Don Coyote,

      ++ Thanks for posting the report.

      I have cygwin-thread-multi (not MSWin32-x86-multi-thread) Perl versions, so I'm not in a position to comment further on that.

      — Ken

Re: cpan: Terminal does not support AddHistory. [openSUSE]
by kcott (Archbishop) on Apr 06, 2025 at 02:14 UTC

    I've been doing some setups using openSUSE Leap 15.6 recently for $work. Here are the zypper packages I used to get the cpan utility running cleanly (you may not need all of these).

    • gcc
    • zip
    • perl-Log-Log4perl
    • perl-Term-ReadLine-Perl
    • perl-local-lib
    • perl-YAML
    • perl-CPAN-DistnameInfo
    • perl-CPAN

    Checking my old notes, this worked the same for openSUSE Leap 15.4. Presumably also good for Leap 15.5; and possibly for (some) versions prior to Leap 15.4.

    Here's the perl & cpan info (cf. Re^2: cpan: Terminal does not support AddHistory. posted earlier):

    kenc@vdesktop35 ~/tmp $ perl -v | head -2 | tail -1 This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-li +nux-thread-multi kenc@vdesktop35 ~/tmp $ cpan cpan shell -- CPAN exploration and modules installation (v2.38) Enter 'h' for help. cpan[1]> o conf pushy_https pushy_https [0] Type 'o conf' to view all configuration items cpan[2]> o conf urllist urllist 0 [https://cpan.org/] 1 [https://cpan.metacpan.org/] Type 'o conf' to view all configuration items cpan[3]> q Lockfile removed. kenc@vdesktop35 ~/tmp

    — Ken

Re: cpan: Terminal does not support AddHistory.
by Anonymous Monk on Aug 16, 2024 at 19:33 UTC
    Ahoy 3 years later!

    To get this to work I also had to install the libreadline package, which on ubuntu is

    sudo apt install libreadline6 libreadline6-dev
    I think you might be able to just install libreadline-dev, but I did it the above way and it worked. Then I had to run
    cpan install Log::Log4perl
    Now I can use up and down to scroll through history, but I also get this message.
    Starting with version 2.29 of the cpan shell, a new download mechanism is the default which exclusively uses cpan.org as the host to download from. The configuration variable pushy_https can be used to (de)select the new mechanism. Please read more about it and make your choice between the old and the new mechanism by running o conf init pushy_https Once you have done that and stored the config variable this dialog will disappear.
    So basically 0 means use the urllist, and 1 or undef means only ever use CPAN and ignore the urllist. Apparently this was in response to a spoofing attack a couple years ago but could cause problems if you try to use a mirror or something like that. There is a question and response about it on stack overlow. https://stackoverflow.com/questions/75523351/cpan-not-using-configured-repo-instead-trying-to-connect-to-cpan-org-when-instal So I ran
    o conf pushy_https 0 o conf commit
    So after that I finally get
    cpan shell -- CPAN exploration and modules installation (v2.36) Enter 'h' for help.
    And I can scroll through my log and no more errors or warnings on startup. Thanks for the heads up man. I stumbled on this trying to install Gtk2 and Gnome2::Canvas which also dont work unless you install them manually from source. Thanks and Good Luck!

      G'day AM,

      No worries about "3 years later" -- for various personal reasons, this is the first time I've logged in for over six months.

      In my original post, I had requested others to report their findings on other systems. Your feedback re Ubuntu is very much appreciated; it's also prompted to me to add a new note about openSUSE (which I've been setting up for $work recently).

      You may find the following CVEs of interest: CVE-2020-16156 and CVE-2023-31484.

      Here's my current cpan shell setup (locally on Cygwin with Perl v5.40.0) for the configuration items you discussed:

      $ perl -v | head -2 | tail -1 This is perl 5, version 40, subversion 0 (v5.40.0) built for cygwin-th +read-multi ken@titan ~/tmp $ cpan cpan shell -- CPAN exploration and modules installation (v2.36) Enter 'h' for help. cpan[1]> o conf pushy_https pushy_https [0] Type 'o conf' to view all configuration items cpan[2]> o conf urllist urllist 0 [https://www.cpan.org/] 1 [https://cpan.metacpan.org/] Type 'o conf' to view all configuration items cpan[3]> q Lockfile removed. ken@titan ~/tmp

      Update: Added perl -v ... command.

      — Ken