在 cygwin64 下运行 CPAN 工具链需要哪些包?

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

我经常在我的 *nix 系统(FreeBSD、Linux、Mac)上使用几个 perl 模块。我总是从 cpan 安装这些。今年早些时候,我需要在 64 位 Windows 系统上使用其中的一些,大约 2 小时后,我安装了当时最新的 Strawberry Perl 软件包,并从 cpan 安装了我想要的模块就像我以前在 *nix 下做的一样。一切都按预期进行。

在另一个 64 位 Windows 系统上,我现在尝试设置一个 cygwin64 环境,而不是安装 Strawberry Perl。在该系统上我们需要一些工具,这些工具在 cygwin64 下已经运行良好,因此将新的 perl 功能添加到现有的 cygwin64 环境中似乎是个好主意。为了在不影响生产环境的情况下测试这种可能性,我在一个单独的、干净的 Windows 系统上执行 trial/error 设置。

我下载了当前的cygwin64安装器,可以正常安装我们过去需要的所有工具。我也可以安装 perl5。但是通过 "cpan install" 安装模块不起作用。 不幸的是,我并没有真正意识到 cpan 依赖的 *nix 包,因为所有依赖项都在我的 unices 上(显然还有 Windows 下的 Strawberry Perl)每个依赖项都是自动安装的,我从来不必关心这些. 我的cygwin64环境明显遗漏了cpan构建过程运行需要的一些包。但是 cygwin64 中的 cpan 在传达缺少的内容或错误的内容方面做得非常糟糕。

我尝试使用 cygwin 安装程序安装 clang、gcc、mingw 和其他开发人员工具的多种组合,但仍然无法 "cpan install desired::module" 工作。根据我使用的包组合,我会收到不同的错误(或错误迹象)。

作为一个相当可靠的起点,能否请您给我一份我最应该安装的 cygwin 包的列表,以便拥有一个 "cpan install ..." 应该成功的环境。


添加#1:

如果我只安装最基本的 cygwin 包(zsh、perl)和那些随附的包,我最终会得到这个...

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

make、gmake、cmake、nmake、gcc、clang 中的任何一个都会产生 "command not found" 响应。

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

 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

那 "Press SPACE and ENTER" 行一直填满我的屏幕,直到我按下 Ctrl+C。

所以,我再次启动 Cygwin 安装程序,并安装 devel/make 包。这样我就有了这个...

$ 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

这次没有关于缺少 "make" 的警告,但相同的 "Press SPACE and ENTER" 行填满了屏幕。仍然存在 "uninitialised $what",以及关于没有适当的文件夹权限的警告。我在其他人的问题中看到过,通常通过重新安装最新的 perl 包来解决(我有最新的)。

那么,我错过了什么包裹? 或者我接受默认值是否在上面做出了错误的选择? 请注意:我在之前的尝试中安装了额外的开发包。但是现在为了简单起见,我只有 "perl" 和 "make".


添加#2

根据Håkon和mob的回答,我再次启动了cygwin安装器,并安装了推荐的包。所以现在我已经安装了 devel/binutils、devel/clang、devel/cmake、devel/gcc-core、devel/gcc-g++、gccmakedep 和 make。 curl 也可用,它已经存在,所以我不需要安装(可能作为依赖项)。

不幸的是,我在开始时仍然得到这个 "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

关于 $what 警告: Cpan.pm 的第 660 到 670 行是这样的...

BEGIN {
my $scalar = '';

sub _hook_into_CPANpm_report
    {
    no warnings 'redefine';

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

我可以通过将第 669 行修改为这个来消除警告...

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

...但这并不能解决为什么 $what 仍然未定义的问题。但是,我最终还是看到 "Press SPACE and ENTER to disable curl" 填满了屏幕。如果我键入 "manual" 并按 Enter 而不是接受默认的 local::lib 选项,也会发生同样的情况。

根据您的 cpan 输出,您可以在重新运行 cpan 之前尝试使用 Cygwin 安装程序安装以下附加包:

  • ALERT: 'make' is an essential tool for building perl Modules. --> 安装 make 包。

  • Press SPACE and ENTER to disable curl,安装 curl 包。另外,我认为包 gccgcc-g++ 是许多 CPAN 模块安装所必需的。然后 libcrypt-devel 可能需要 SSH 相关的东西,libreadline-devel 很高兴在 Cygwin 终端 window.

  • 中调用历史记录
  • 可选地,可以安装 GNU MP Bignum 库:libgmp-devel。当我收到你的反馈时,我会添加更多:)

根据我自己安装的一组软件包以及我对哪些软件包在 cpan 工具链中有用的记忆:

binutils
bzip2
clang
cmake
gcc-core
gcc-g++
gccmakedep
make
curl  and/or  wget

事情发生了有趣的变化。我注意到,即使我从一开始就安装了 curl(带有最基本的默认 cygwin 环境),我也从未安装过它(不是通过 cygwin 安装程序)。

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

并且有一个 curl 包可用于标记安装。所以我通过cygwin安装程序安装了Net/curl,然后得到了这个。

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

此时,cpan 不再打印 "Press SPACE and ENTER to disable curl" 消息,而是开始按预期运行。

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

现在我可以通过通常的 "install desired::package" 方法开始构建模块了。所以我终于到达了我想到达的地方。 有趣的是,我想构建的每个模块都构建失败。但至少他们以我熟悉的 *nix 方式失败了。所以这又是另一个问题了。

回答我最初的问题:要在 cygwin 下运行 "cpan",您必须至少安装这些包。 . .

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

最后一个,Net/curl非常重要。因为基本的 cygwin 环境确实已经有一个功能性的 curl,但是 "cpan" 不适用于它。您必须通过 cygwin 安装程序安装 Net/curl 包。这将消除在 运行 "cpan".

上填满 window 的 "Press SPACE and ENTER to disable curl" 消息