oracle-databasemacosperldbidbd

Cannot install DBD::Oracle on macOS Big Sur => dependent dylib '@rpath/libclntsh.dylib.19.1' not found


I cannot build and install Oracle Instant Client 19.8 on macOS Big Sur 11.2.1. I get the following error:

Error:  Can't load '/Users/x/.cpanm/work/1613898291.17798/DBD-Oracle-1.80/blib/arch/auto/DBD/Oracle/Oracle.bundle' for module DBD::Oracle: dlopen(/Users/x/.cpanm/work/1613898291.17798/DBD-Oracle-1.80/blib/arch/auto/DBD/Oracle/Oracle.bundle, 0x0002): dependent dylib '@rpath/libclntsh.dylib.19.1' not found for '/Users/x/.cpanm/work/1613898291.17798/DBD-Oracle-1.80/blib/arch/auto/DBD/Oracle/Oracle.bundle'. relative file paths not allowed '@rpath/libclntsh.dylib.19.1' at /System/Library/Perl/5.28/darwin-thread-multi-2level/DynaLoader.pm line 197.

It appears Big Sur doesn't pass the DYLD_LIBRARY_PATH environment variable to sub-shells:

Your DYLD_LIBRARY_PATH env var is set to ''
WARNING: Your DYLD_LIBRARY_PATH env var doesn't include '/opt/instantclient_19_8' but probably needs to.

I have tried:

but I can't seem to figure it out. Your help is greatly appreciated. To re-produce:

  1. Install Oracle Instant Client 19.8 onto /opt/instantclient_19_8

  2. macOS Big Sur, set the neccesssary environment variables.

% uname -v
Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64
% echo $DYLD_LIBRARY_PATH
/opt/instantclient_19_8

% env | grep -E 'PERL|ORACLE|DYLD'
PERL_LOCAL_LIB_ROOT=/Users/x/.perl5
PERL_MB_OPT=--install_base /Users/x/.perl5
PERL_MM_OPT=INSTALL_BASE=/Users/x/.perl5
PERL5LIB=/Users/x/.perl5/lib/perl5
ORACLE_HOME=/opt/instantclient_19_8

and that's my first problem there. DYLD_LIBRARY_PATH is purged.

  1. Install cpanm into ~/.perl5
% curl -fsSL http://cpanmin.us | perl - -l ~/.perl5 App::cpanminus local::lib
--> Working on App::cpanminus
Fetching http://www.cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7044.tar.gz ... OK
Configuring App-cpanminus-1.7044 ... OK
Building and testing App-cpanminus-1.7044 ... OK
Successfully installed App-cpanminus-1.7044
--> Working on local::lib
Fetching http://www.cpan.org/authors/id/H/HA/HAARG/local-lib-2.000024.tar.gz ... OK
Configuring local-lib-2.000024 ... OK
Building and testing local-lib-2.000024 ... OK
Successfully installed local-lib-2.000024
2 distributions installed
  1. Force install DBI, to avoid any conflicts with the built-in version:
% cpanm DBI
DBI is up to date. (1.643)
% cpanm DBI --force
--> Working on DBI
Fetching http://www.cpan.org/authors/id/T/TI/TIMB/DBI-1.643.tar.gz ... OK
Configuring DBI-1.643 ... OK
Building and testing DBI-1.643 ... FAIL
! Testing DBI-1.643 failed but installing it anyway.
Successfully reinstalled DBI-1.643
1 distribution installed
  1. Install DBD::Oracle - always fails.
% cpanm DBD::Oracle
--> Working on DBD::Oracle
Fetching http://www.cpan.org/authors/id/M/MJ/MJEVANS/DBD-Oracle-1.80.tar.gz ... OK
==> Found dependencies: Test::NoWarnings
--> Working on Test::NoWarnings
Fetching http://www.cpan.org/authors/id/A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz ... OK
Configuring Test-NoWarnings-1.04 ... OK
Building and testing Test-NoWarnings-1.04 ... OK
Successfully installed Test-NoWarnings-1.04
Configuring DBD-Oracle-1.80 ... OK
Building and testing DBD-Oracle-1.80 ... FAIL
! Installing DBD::Oracle failed. See /Users/x/.cpanm/work/1613898291.17798/build.log for details. Retry with --force to force install it.
1 distribution installed

Solution

  • The problem is that the DYLD_LIBRARY_PATH environment variable is not propagated to perl when running make test as described here. Instead of running cpanm DBD::Oracle, you can download the module run the tests manually using e.g. prove. The following worked for me (macOS BigSur 11.2.1), perlbrew perl version 5.32.0:

    NOTES: