Search code examples
perlcygwincpan

What packages do I need for a working CPAN tool chain under cygwin64?


There are a couple of perl modules I often use on my *nix systems (FreeBSD, Linux, Mac). I always install these from cpan. Earlier this year I needed to use some of these on a 64-bit Windows system, and in about 2 hours I got the then-most-recent Strawberry Perl package installed, and from cpan I installed the modules of my desire the same way I used to do under *nix. Everything worked as expected.

On another 64-bit Windows system I am now attempting to set up a cygwin64 environment instead of installing Strawberry Perl. There are a handful of tools we need on that system, and those are already working fine under cygwin64, so it seems like a good idea to add the new perl functionality to the already existing cygwin64 environment. To test this possibility without messing with the production environment, I am performing trial/error setups on a separate, clean Windows system.

I downloaded the now current cygwin64 installer, and can get all the tools we required in the past installed fine. I can also get perl5 installed. But installing modules via "cpan install" does not work. Unfortunatelly, I am not really aware of the *nix packages that cpan depends on, because all on my unices (and apparently with Strawberry Perl under Windows too) every dependency is installed automatically, and I never had to care about these. My cygwin64 environment obviously misses some packages required by the build process run by cpan. But cpan in cygwin64 does a very bad job of communicating what is missing or what is wrong.

I tried installing multiple combinations of clang, gcc, mingw and other developer tools using the cygwin installer, but still could not get "cpan install desired::module" working. Depending on the package mixture I used, I get different errors (or signs of errors).

As a fairly reliable starting point, could you please give me a list of cygwin packages I should most certainly install, in order to have an environment where "cpan install ..." is supposed to succeed.


Addition#1:

If I install only the most basic cygwin packages (zsh, perl) and those that come anyway, I end up with this ...

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

Any of make, gmake, cmake, nmake, gcc, clang results in a "command not found" response.

Starting cpan does this ...

$ 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]

 ALERT: 'make' is an essential tool for building perl Modules.
Please make sure you have 'make' (or some equivalent) working.

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
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 "Press SPACE and ENTER" line keeps filling my screen until I press Ctrl+C.

So, I start the Cygwin installer again, and install the devel/make package. That way I have this ...

$ make -v
GNU Make 4.2.1
Built for x86_64-unknown-cygwin
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ 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

This time there is no warning about "make" missing, but the same "Press SPACE and ENTER" line fills the screen. There is still that "uninitialised $what", and the warning about not having proper permissions to folders. Which I have seen in questions by others, usually fixed by reinstalling the perl package with the most recent one (I have the most recent one).

So, what package do I miss? Or did I make a wrong choice above by accepting the default? Please note: I have installed additional devel packages with my earlier attempts. But to keep things simple for now, I only have "perl" and "make".


Addition#2

Following the answers by Håkon and mob, I started the cygwin installer again, and installed the recommended packages. So now I have devel/binutils, devel/clang, devel/cmake, devel/gcc-core, devel/gcc-g++, gccmakedep, and make installed. Also available is curl, which was already present so I did not need to install (perhaps came as a dependency).

Unfortunately, I still get this when starting "cpan":

$ 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

Regarding the $what warning: Lines 660 to 670 of Cpan.pm go like this ...

BEGIN {
my $scalar = '';

sub _hook_into_CPANpm_report
    {
    no warnings 'redefine';

    *CPAN::Shell::myprint = sub {
        my($self,$what) = @_;
        $scalar .= $what;

I can get rid of the warning by modifying line 669 to this ...

$scalar .= ($what // '');

... but this does not solve the problem of why $what is undefined anyway. However, I still end up seeing that "Press SPACE and ENTER to disable curl" filling up the screen. And the same happens if I type "manual" and hit Enter instead of accepting the default local::lib option.


Solution

  • Things took an interesting turn. I noticed that even though I had curl from the very beginning (came with the most basic, default cygwin environment), I never installed it (not via the cygwin installer).

    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 there is a curl package available to mark for install. So I installed Net/curl via cygwin setup, and then got this.

    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
    

    At that point, cpan no longer printed the "Press SPACE and ENTER to disable curl" message, but started to behave as expected.

    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]>
    

    And now I can start building modules by the usual "install desired::package" method. So I finally got where I wanted to get. Interestingly, each module I wanted to build failed to build. But at least they failed in a way that I am familiar with from *nix. So this is now another problem for another day.

    To answer my original question: to get a working "cpan" under cygwin, you must install at least these packages . . .

    • devel/binutils
    • devel/clang
    • devel/cmake
    • devel/gcc-core
    • devel/gcc-g++
    • devel/gccmakedep
    • devel/make
    • Net/curl

    The last one, Net/curl is extremely important. Because the basic cygwin environment does have a functional curl already, but "cpan" does not work with that. You must install the Net/curl package via cygwin setup. That will get rid of the "Press SPACE and ENTER to disable curl" messages filling up the window upon running "cpan".