andk / cpanpm

CPAN.pm
87 stars 79 forks source link

cpan displays "Press SPACE and ENTER to disable curl" under cygwin64 #128

Closed KeveNagy closed 5 years ago

KeveNagy commented 5 years ago

The problem

keve@cygtest ~
$ perl -v

This is perl 5, version 26, subversion 3 (v5.26.3) built for     x86_64-cygwin-threads-multi
(with 7 registered patches, see perl -V for more detail)

Copyright 1987-2018, Larry Wall

Perl may be copied only under the terms of either the Artistic License or     the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

keve@cygtest ~
$ curl --version
curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
Release-Date: [unreleased]
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps     telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL
$ cpan
Loading internal null logger. Install Log::Log4perl for logging messages
Sorry, we have to rerun the configuration dialog for CPAN.pm due to
some missing parameters. Configuration will be written to
 <</home/Valaki/.cpan/CPAN/MyConfig.pm>>

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes]

Use of uninitialized value $what in concatenation (.) or string at /usr/share/perl5/5.26/App/Cpan.pm line 669, <STDIN> line 1.
 <install_help>

Warning: You do not have write permission for Perl library directories.

To install modules, you need to configure a local Perl library directory or
escalate your privileges.  CPAN can help you by bootstrapping the local::lib
module or by configuring itself to use 'sudo' (if available).  You may also
resolve this problem manually if you need to customize your setup.

What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
 [local::lib]

Press SPACE and ENTER to disable curl
Press SPACE and ENTER to disable curl
Press SPACE and ENTER to disable curl
Press SPACE and ENTER to disable curl
Press SPACE and ENTER to disable curl
Press SPACE and ENTER to disable curl

... and that message keeps repeating in an infinite loop, until I break it with a Ctrl+C.

Solution

You must install the Net/curl package via cygwin setup. The source of confusion is that a different version of curl comes with the most basic cygwin setup, but cpan does not work with that.

keve@cygtest ~
$ curl --version
curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
Release-Date: [unreleased]
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps     telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL

keve@cygtest ~
$ which curl
/cygdrive/c/Windows/system32/curl

And here is what you get once Net/curl is installed.

keve@cygtest ~
$ which curl
/usr/bin/curl

keve@cygtest ~
$ curl --version
curl 7.65.0 (x86_64-pc-cygwin) libcurl/7.65.0 OpenSSL/1.1.1b zlib/1.2.11 brotli/1.0.7 libidn2/2.0.4 libpsl/0.18.0 (+libidn2/2.0.2) libssh/0.8.7/openssl/zlib nghttp2/1.37.0
Release-Date: 2019-05-22
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli Debug GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP TrackMemory UnixSockets

keve@cygtest ~
$ which -a curl
/usr/bin/curl
/cygdrive/c/Windows/system32/curl

So now you have two different versions of curl available in your cygwin environment, and the one installed via the Net/curl package takes precedence. Now when you start cpan, you get something like this ...

keve@cygtest ~
$ cpan
Loading internal null logger. Install Log::Log4perl for logging messages
Sorry, we have to rerun the configuration dialog for CPAN.pm due to
some missing parameters. Configuration will be written to
 <</home/keve/.cpan/CPAN/MyConfig.pm>>

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes]

Use of uninitialized value $what in concatenation (.) or string at /usr/share/perl5/5.26/App/Cpan.pm line 669, <STDIN> line 1.
 <install_help>

Warning: You do not have write permission for Perl library directories.

To install modules, you need to configure a local Perl library directory or
escalate your privileges.  CPAN can help you by bootstrapping the local::lib
module or by configuring itself to use 'sudo' (if available).  You may also
resolve this problem manually if you need to customize your setup.

What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
 [local::lib]

Autoconfiguration complete.

Attempting to bootstrap local::lib...

Writing /home/keve/.cpan/CPAN/MyConfig.pm for bootstrap...
commit: wrote '/home/keve/.cpan/CPAN/MyConfig.pm'
Fetching with HTTP::Tiny:
http://www.cpan.org/authors/01mailrc.txt.gz
Reading '/home/keve/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with HTTP::Tiny:
http://www.cpan.org/modules/02packages.details.txt.gz
Reading '/home/keve/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Sat, 01 Jun 2019 09:17:02 GMT
  HTTP::Date not available
.............
  New CPAN.pm version (v2.26) available.
  [Currently running version is v2.18]
  You might want to try
    install CPAN
    reload cpan
  to both upgrade CPAN.pm and run the new version without leaving
  the current session.

...............................................................DONE
Fetching with HTTP::Tiny:
http://www.cpan.org/modules/03modlist.data.gz
Reading '/home/keve/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /home/keve/.cpan/Metadata
Fetching with HTTP::Tiny:
http://www.cpan.org/authors/id/H/HA/HAARG/local-lib-2.000024.tar.gz
Fetching with HTTP::Tiny:
http://www.cpan.org/authors/id/H/HA/HAARG/CHECKSUMS
Checksum for /home/keve/.cpan/sources/authors/id/H/HA/HAARG/local-lib-2.000024.tar.gz ok
'YAML' not installed, will not store persistent state
Configuring H/HA/HAARG/local-lib-2.000024.tar.gz with Makefile.PL
Attempting to create directory /home/keve/perl5

Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for local::lib
Writing MYMETA.yml and MYMETA.json
  HAARG/local-lib-2.000024.tar.gz
  /usr/bin/perl Makefile.PL --bootstrap -- OK
Running make for H/HA/HAARG/local-lib-2.000024.tar.gz
cp lib/local/lib.pm blib/lib/local/lib.pm
cp lib/POD2/PT_BR/local/lib.pod blib/lib/POD2/PT_BR/local/lib.pod
cp lib/POD2/DE/local/lib.pod blib/lib/POD2/DE/local/lib.pod
cp lib/lib/core/only.pm blib/lib/lib/core/only.pm
Manifying 4 pod documents
  HAARG/local-lib-2.000024.tar.gz
  /usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 "/usr/bin/perl.exe" "-I/home/keve/perl5/lib/perl5" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/bad_variables.t ...... ok
t/carp-mismatch.t ...... ok
t/classmethod.t ........ ok
t/de-dup.t ............. ok
t/lib-core-only.t ...... ok
t/pipeline.t ........... ok
t/shell.t .............. ok
t/stackable.t .......... ok
t/subroutine-in-inc.t .. ok
t/taint-mode.t ......... ok
All tests successful.
Files=10, Tests=172, 29 wallclock secs ( 0.03 usr  0.17 sys +  4.24 cusr 11.30 csys = 15.74 CPU)
Result: PASS
  HAARG/local-lib-2.000024.tar.gz
  /usr/bin/make test -- OK
Running make install
Manifying 4 pod documents
Installing /home/keve/perl5/lib/perl5/lib/core/only.pm
Installing /home/keve/perl5/lib/perl5/local/lib.pm
Installing /home/keve/perl5/lib/perl5/POD2/DE/local/lib.pod
Installing /home/keve/perl5/lib/perl5/POD2/PT_BR/local/lib.pod
Installing /home/keve/perl5/man/man3/lib.core.only.3pm
Installing /home/keve/perl5/man/man3/local.lib.3pm
Installing /home/keve/perl5/man/man3/POD2.DE.local.lib.3pm
Installing /home/keve/perl5/man/man3/POD2.PT_BR.local.lib.3pm
Appending installation info to /home/keve/perl5/lib/perl5/x86_64-cygwin-threads-multi/perllocal.pod
  HAARG/local-lib-2.000024.tar.gz
  /usr/bin/make install  -- OK

local::lib is installed. You must now add the following environment variables
to your shell configuration files (or registry, if you are on Windows) and
then restart your command line shell and CPAN before installing modules:

PATH="/home/keve/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/keve/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/keve/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/keve/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/keve/perl5"; export PERL_MM_OPT;

Would you like me to append that to /home/keve/.bashrc now? [yes]

commit: wrote '/home/keve/.cpan/CPAN/MyConfig.pm'

You can re-run configuration any time with 'o conf init' in the CPAN shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v2.18)
Enter 'h' for help.

cpan[1]>

Note:

I was told the "Use of uninitialized value $what in concatenation (.) or string at /usr/share/perl5/5.26/App/Cpan.pm line 669" warning is harmless and can be safely ignored. You can upgrade cpan itself via cpan CPAN, and that warning will no longer show up. Alternatively you can change line 669 of CPAN.pm from $scalar .= $what; to $scalar .= ($what // '');.

Other than the above, for cpan to work properly under cygwin64, make sure you have at least the below packages installed.

hakonhagland commented 3 years ago

I have installed Net/curl but it still does not work:

$ which -a curl
/usr/bin/curl
/cygdrive/c/WINDOWS/system32/curl
$ perl --version
This is perl 5, version 30, subversion 3 (v5.30.3) built for x86_64-cygwin-threads-multi
(with 7 registered patches, see perl -V for more detail)
$ cpan
Loading internal logger. Log::Log4perl recommended for better logging
Sorry, we have to rerun the configuration dialog for CPAN.pm due to
some missing parameters. Configuration will be written to
 <</home/hakon/.cpan/CPAN/MyConfig.pm>>

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes]

Use of uninitialized value $what in concatenation (.) or string at /usr/share/perl5/5.30/App/Cpan.pm line 679, <STDIN> line 1.
 <install_help>

Warning: You do not have write permission for Perl library directories.

To install modules, you need to configure a local Perl library directory or
escalate your privileges.  CPAN can help you by bootstrapping the local::lib
module or by configuring itself to use 'sudo' (if available).  You may also
resolve this problem manually if you need to customize your setup.

What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
 [local::lib]

Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
Press SPACE and ENTER to disable patch
[...]
hakonhagland commented 3 years ago

It seems that it enters an infinite loop at line 1549 in FirstTime.pm if any of the programs : make, bzip2, gzip, tar, unzip, gpg, patch, applypatch, wget, or curl exists but does somehow not behave as expected? I am not sure since I got it to work before I could test more.

I noticed that the patch program was picked up from the Strawberry perl installation:

$ which patch
/cygdrive/c/Strawberry/c/bin/patch

So I decided to install the package patch, and after that I get

$ which patch
/usr/bin/patch

If I now run cpan it works as expected:

$ cpan
Loading internal logger. Log::Log4perl recommended for better logging
Sorry, we have to rerun the configuration dialog for CPAN.pm due to
some missing parameters. Configuration will be written to
 <</home/hakon/.cpan/CPAN/MyConfig.pm>>

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes]

Use of uninitialized value $what in concatenation (.) or string at /usr/share/perl5/5.30/App/Cpan.pm line 679, <STDIN> line 1.
 <install_help>

Warning: You do not have write permission for Perl library directories.

To install modules, you need to configure a local Perl library directory or
escalate your privileges.  CPAN can help you by bootstrapping the local::lib
module or by configuring itself to use 'sudo' (if available).  You may also
resolve this problem manually if you need to customize your setup.

What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
 [local::lib]

Autoconfiguration complete.

Attempting to bootstrap local::lib...

Writing /home/hakon/.cpan/CPAN/MyConfig.pm for bootstrap...
commit: wrote '/home/hakon/.cpan/CPAN/MyConfig.pm'
Fetching with LWP:
http://www.cpan.org/authors/01mailrc.txt.gz
Reading '/home/hakon/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with LWP:
http://www.cpan.org/modules/02packages.details.txt.gz
Reading '/home/hakon/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Fri, 15 Jan 2021 14:41:02 GMT
.............
  New CPAN.pm version (v2.28) available.
  [Currently running version is v2.22]
  You might want to try
    install CPAN
    reload cpan
  to both upgrade CPAN.pm and run the new version without leaving
  the current session.

...............................................................DONE
Fetching with LWP:
http://www.cpan.org/modules/03modlist.data.gz
Reading '/home/hakon/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /home/hakon/.cpan/Metadata
Fetching with LWP:
http://www.cpan.org/authors/id/H/HA/HAARG/local-lib-2.000024.tar.gz
Fetching with LWP:
http://www.cpan.org/authors/id/H/HA/HAARG/CHECKSUMS
Checksum for /home/hakon/.cpan/sources/authors/id/H/HA/HAARG/local-lib-2.000024.tar.gz ok
'YAML' not installed, will not store persistent state
Configuring H/HA/HAARG/local-lib-2.000024.tar.gz with Makefile.PL
Attempting to create directory /home/hakon/perl5
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for local::lib
Writing MYMETA.yml and MYMETA.json
  HAARG/local-lib-2.000024.tar.gz
  /usr/bin/perl Makefile.PL --bootstrap -- OK
Running make for H/HA/HAARG/local-lib-2.000024.tar.gz
cp lib/POD2/DE/local/lib.pod blib/lib/POD2/DE/local/lib.pod
cp lib/POD2/PT_BR/local/lib.pod blib/lib/POD2/PT_BR/local/lib.pod
cp lib/lib/core/only.pm blib/lib/lib/core/only.pm
cp lib/local/lib.pm blib/lib/local/lib.pm
Manifying 4 pod documents
  HAARG/local-lib-2.000024.tar.gz
  /usr/bin/make -- OK
Running make test for HAARG/local-lib-2.000024.tar.gz
PERL_DL_NONLAZY=1 "/usr/bin/perl.exe" "-I/home/hakon/perl5/lib/perl5" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/bad_variables.t ...... ok
t/carp-mismatch.t ...... ok
t/classmethod.t ........ ok
t/de-dup.t ............. ok
t/lib-core-only.t ...... ok
t/pipeline.t ........... ok
t/shell.t .............. ok
t/stackable.t .......... ok
t/subroutine-in-inc.t .. ok
t/taint-mode.t ......... ok
All tests successful.
Files=10, Tests=148, 18 wallclock secs ( 0.08 usr  0.14 sys +  2.93 cusr  7.21 csys = 10.36 CPU)
Result: PASS
  HAARG/local-lib-2.000024.tar.gz
  /usr/bin/make test -- OK
Running make install for HAARG/local-lib-2.000024.tar.gz
Manifying 4 pod documents
Installing /home/hakon/perl5/lib/perl5/lib/core/only.pm
Installing /home/hakon/perl5/lib/perl5/local/lib.pm
Installing /home/hakon/perl5/lib/perl5/POD2/DE/local/lib.pod
Installing /home/hakon/perl5/lib/perl5/POD2/PT_BR/local/lib.pod
Installing /home/hakon/perl5/man/man3/lib.core.only.3pm
Installing /home/hakon/perl5/man/man3/local.lib.3pm
Installing /home/hakon/perl5/man/man3/POD2.DE.local.lib.3pm
Installing /home/hakon/perl5/man/man3/POD2.PT_BR.local.lib.3pm
Appending installation info to /home/hakon/perl5/lib/perl5/x86_64-cygwin-threads-multi/perllocal.pod
  HAARG/local-lib-2.000024.tar.gz
  /usr/bin/make install  -- OK

local::lib is installed. You must now add the following environment variables
to your shell configuration files (or registry, if you are on Windows) and
then restart your command line shell and CPAN before installing modules:

PATH="/home/hakon/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/hakon/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/hakon/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/hakon/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/hakon/perl5"; export PERL_MM_OPT;

Would you like me to append that to /home/hakon/.bashrc now? [yes]

commit: wrote '/home/hakon/.cpan/CPAN/MyConfig.pm'

You can re-run configuration any time with 'o conf init' in the CPAN shell
Terminal does not support AddHistory.

To fix enter>  install Term::ReadLine::Perl

cpan shell -- CPAN exploration and modules installation (v2.22)
Enter 'h' for help.