如何在macOS 10.13 High Sierra

时间:2017-10-10 07:32:00

标签: macos perl macos-high-sierra

我最近升级到macOS 10.13 High Sierra,并在尝试安装更新版本的Perl(5.26.1)后遇到问题。问题的关键在于cpan/DB_File的自检在macOS 10.13 High Sierra(家用笔记本电脑)上始终失败,但在macOS 10.12 Sierra(工作笔记本电脑)上取得了成功。

以下是显示失败的安装日志部分:

../cpan/Config-Perl-V/t/30_plv5240.t ............................... ok
../cpan/Config-Perl-V/t/31_plv52511.t .............................. ok
../cpan/DB_File/t/db-btree.t ....................................... ok
Use of uninitialized value $value in string eq at t/db-hash.t line 224.
Use of uninitialized value $values[0] in string eq at t/db-hash.t line 224.
Use of uninitialized value $value in lc at t/db-hash.t line 224.
Use of uninitialized value $h{""} in string eq at t/db-hash.t line 243.
Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Use of uninitialized value $foo[18] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[36] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[48] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[58] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[59] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[60] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[62] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[63] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[92] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[114] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[140] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[187] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[188] in join or string at t/db-hash.t line 261.
Use of uninitialized value $foo[189] in join or string at t/db-hash.t line 261.
Use of uninitialized value $h{"Fred"} in string eq at t/db-hash.t line 572.
Use of uninitialized value $v in concatenation (.) or string at t/db-hash.t line 748.
../cpan/DB_File/t/db-hash.t ........................................ 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 76/166 subtests 

无论是使用perlbrew install perl-5.26.1安装还是只是下载the Perl tarfile并手动安装,我都能重复同样的失败。当我尝试调试有问题的测试t/db-hash.t时,我可以看到测试哈希%h已经创建并且正在测试文件中填充,但是当我print Dumper(\%h)时,我看到了hash看起来有正确的键,但所有值都是undef,而不是测试脚本中分配的值。

这些undef值导致测试失败。奇怪的是,当我打印整个哈希或尝试创建哈希值数组时,会显示未定义的值。如果我要求特定的散列密钥值,例如my $value = $h{key},值打印正常。

问题:

  • 如何解决这个问题,以便我可以在macOS 10.13上安装新的Perl?
  • 什么破了?这曾经用于macOS 10.12。

2 个答案:

答案 0 :(得分:13)

TL; DR

这是有效的:

  1. 安装Berkeley DB。我使用Homebrew,但您可以在Oracle site获取源文件。

    brew install berkeley-db
    
  2. 安装Perl。我使用Perlbrew,但您可以在Perl site获取源文件。

    perlbrew install perl-5.26.1
    
  3. 部分解释

    回顾失败的安装日志,DB_File部分附近有警告提示线索:

    ...
    ./miniperl -Ilib make_ext.pl lib/auto/DB_File/DB_File.bundle  MAKE="/Applications/Xcode.app/Contents/Developer/usr/bin/make" LIBPERL_A=libperl.a LINKTYPE=dynamic
    Parsing config.in...
    Looks Good.
    Warning (mostly harmless): No library found for -ldb
    Generating a Unix-style Makefile
    Writing Makefile for DB_File
    ...
    

    找不到db库,主要无害。

    根据DB_File module的文档,它是......

      

    ...允许Perl程序使用Berkeley DB提供的工具的模块......

    安装berkeley-db后,Perl安装日志的相同部分不再显示相同的警告:

    ...
    ./miniperl -Ilib make_ext.pl lib/auto/DB_File/DB_File.bundle  MAKE="/Applications/Xcode.app/Contents/Developer/usr/bin/make" LIBPERL_A=libperl.a LINKTYPE=dynamic
    Parsing config.in...
    Looks Good.
    Generating a Unix-style Makefile
    Writing Makefile for DB_File
    ...
    

    在此过程中,先前失败的测试通过,允许安装成功完成:

    ...
    ../cpan/DB_File/t/db-btree.t ....................................... ok
    ../cpan/DB_File/t/db-hash.t ........................................ ok
    ../cpan/DB_File/t/db-recno.t ....................................... ok
    ...
    

    我无法在网上找到任何关于为什么Berkeley DB似乎从macOS 10.13 High Sierra中丢失的文档,以及这是否与以前的macOS版本相比有所改变。

    非常感谢Tim D帮助我排除故障。

答案 1 :(得分:1)

要安装perl本身(包含DB_File模块),或从CPAN安装DB_File模块,解决方案是相同的:编辑其config.in以指向berkeley-db的正确位置。

例如,我已经使用sudo port install db48通过macports安装了db48软件包。在perl下载本身中,我导航至cpan / DB_File并编辑其config.in,从而更改了现有的INCLUDE和LIB分配:

INCLUDE    = /opt/local/include/db48
LIB        = /opt/local/lib/db48

然后我可以恢复perl的构建过程,并且可以编译DB_File。

参考文献:

Perl RT#133280
CPAN RT#125238