Reputation: 376
I recently upgraded to macOS 10.13 High Sierra and shortly after encountered a problem attempting to install a more recent version of Perl (5.26.1). The gist of the problem is that the self-tests for cpan/DB_File
consistently failed on macOS 10.13 High Sierra (home laptop) but succeeded on macOS 10.12 Sierra (work laptop).
Here's the section of the installation log showing the failure:
../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
I was able to repeat this same failure whether installing using perlbrew install perl-5.26.1
or simply downloading the Perl tarfile and installing manually. When I try to debug the test in question t/db-hash.t
, I can see that the test hash %h
is created and is being populated in the test file, but when I print Dumper(\%h)
I see that the hash looks to have the right keys, but all of the values are undef
, rather than the values being assigned in the test script.
These undef
values are causing the test failure. Oddly, the undefined values show up when I print the whole hash or try to make an array of the hash values. If I ask for a specific hash key's value, e.g. my $value = $h{key}
, the value prints fine.
Questions:
Upvotes: 12
Views: 4932
Reputation: 53966
To install perl itself (which contains the DB_File module), or to install the DB_File module from CPAN, the solution is the same: edit its config.in
to point to the proper location of berkeley-db.
For example, I have installed the db48 package via macports with sudo port install db48
. In the perl download itself, I navigate to cpan/DB_File and edit its config.in
, changing the existing INCLUDE and LIB assignments thusly:
INCLUDE = /opt/local/include/db48
LIB = /opt/local/lib/db48
I can then resume the perl build process and DB_File can compile.
References:
Upvotes: 2
Reputation: 376
Here's what worked:
Install Berkeley DB. I use Homebrew, but you can get the source files at the Oracle site.
brew install berkeley-db
Install Perl. I use Perlbrew, but you can get the source files at the Perl site.
perlbrew install perl-5.26.1
Looking back through the failed installation log, there is a warning near the DB_File
sections that gives a clue:
...
./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
...
No db
library found, mostly harmless.
According to the docs for the DB_File
module, it is...
... a module which allows Perl programs to make use of the facilities provided by Berkeley DB...
After installing berkeley-db
, the same section of the Perl installation log no longer shows the same warning:
...
./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
...
And further along the process, the previously failed tests pass, allowing installation to complete successfully:
...
../cpan/DB_File/t/db-btree.t ....................................... ok
../cpan/DB_File/t/db-hash.t ........................................ ok
../cpan/DB_File/t/db-recno.t ....................................... ok
...
I haven't been able to find any documentation online about why Berkeley DB appears to be missing from macOS 10.13 High Sierra, and whether that was a change from previous macOS versions, as it seems.
Many thanks to Tim D for helping me troubleshoot.
Upvotes: 13