2

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:

  • Installing in the default path: ~/Downloads/instantclient_19_8
  • Installing in ~/lib or /usr/local/lib
  • Replacing the symlinks with absolute paths
  • Using install_name_tool to modify id and change @rpath but got warning: changes being made to the file will invalidate the code signature

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
h q
  • 1,168
  • 2
  • 10
  • 23
  • See also [DYLD_LIBRARY_PATH environment variable is not forwarded to external command in Makefile on macOS](https://stackoverflow.com/q/63629878/2173773) – Håkon Hægland Feb 21 '21 at 13:30
  • Thanks @HåkonHægland. I recognize that, but what can I do about it? – h q Feb 21 '21 at 13:47
  • Try to run the tests directly (not indirectly with `make test`) No solution is not yet found for [the same problem for DBD::mysql](https://github.com/perl5-dbi/DBD-mysql/issues/322) – Håkon Hægland Feb 21 '21 at 13:54
  • Try manually download, configure, make, make test, make install so you can adjust configure and makefile. – ulix Feb 21 '21 at 14:08
  • Thanks @ulix. I'm struggling with that too. `make test` fails. – h q Feb 22 '21 at 05:47
  • @hq Can you try [this](https://github.com/perl5-dbi/DBD-Oracle/pull/129) PR ? – Håkon Hægland Apr 13 '21 at 22:40
  • @Håkon Hægland I don't believe you can use `otool` while System Integrity Protection is turned on. The library becomes unusable. I'll try again, and update this comment. – h q Apr 14 '21 at 12:16
  • @hq *"I don't believe you can use otool while System Integrity Protection is turned on"* I am not sure what you mean? I have SIP turned on. Are you referring to the PR? The PR is not using `otool`, it is just modifying `Makefile.PL` such that the linker includes rpath in the generated `Oracle.bundle` file. By doing it this way, we don't have to use the DYLD_LIBRARY_PATH variable (which causes problems due to [this](https://stackoverflow.com/q/63629878/2173773) issue) – Håkon Hægland Apr 14 '21 at 13:21

1 Answers1

5

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:

  • Download and install instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg and instantclient-sdk-macos.x64-19.8.0.0.0dbru.dmg from https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html

  • Install DBD::Oracle (without running make test)

    $ wget https://cpan.metacpan.org/authors/id/M/MJ/MJEVANS/DBD-Oracle-1.80.tar.gz
    $ tar zxvf DBD-Oracle-1.80.tar.gz
    $ cd DBD-Oracle-1.80
    $ export DYLD_LIBRARY_PATH=/Users/hakonhaegland/Downloads/instantclient_19_8
    $ export ORACLE_HOME=/Users/hakonhaegland/Downloads/instantclient_19_8
    $ cpanm --installdeps .
    $ perl Makefile.PL
    $ make
    $ prove -bv t  
    $ make install
    

NOTES:

Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174
  • Thank you. This is still not working for me. Two questions: 1) Are you using the DBI library that's shipped with Big Sur? 2) What's the output of `otool -L libclntsh.dylib.19.1`? Is it `@rpath/libclntsh.dylib.19.1` (like me) or is it `/Users/hakonhaegland/Downloads/instantclient_19_8/libnnz19.dylib` (like I think it should be)? – h q Feb 22 '21 at 05:46
  • I get the same [output](https://pastebin.com/cKVkA5XU) from `otool -L` – Håkon Hægland Feb 22 '21 at 11:26
  • *"This is still not working for me.."* Strange, do you get the same error when you run `prove -vb t` as when you run `make test` ? – Håkon Hægland Feb 22 '21 at 11:28
  • *"Are you using the DBI library that's shipped with Big Sur?"* Do you mean the Perl module `DBI` ? – Håkon Hægland Feb 22 '21 at 11:29
  • Thanks @Håkon. Yes, I was referring to the `DBI` module that's shipped with Big Sur, Despite being the same version, I get `make: *** No rule to make target '/System/Library/Perl/Extras/5.28/darwin-thread-multi-2level/auto/DBI/Driver_xst.h', needed by 'Oracle.xsi'. Stop.` So I force install `DBI` to proceed. – h q Feb 23 '21 at 14:27
  • `prove -bv t` unfortunately produces the same exact error. `Can't load '/Users/x/.cpanm/work/1614090296.40854/DBD-Oracle-1.80/blib/arch/auto/DBD/Oracle/Oracle.bundle' for module DBD::Oracle: dlopen(/Users/x/.cpanm/work/1614090296.40854/DBD-Oracle-1.80/blib/arch/auto/DBD/Oracle/Oracle.bundle, 0x0001): dependent dylib '@rpath/libclntsh.dylib.19.1' not found for '/Users/x/.cpanm/work/1614090296.40854/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` – h q Feb 23 '21 at 14:29
  • *"So I force install DBI to proceed.."* I think you are using the system perl together with [local::lib](https://metacpan.org/pod/local::lib), whereas I am using [perlbrew](https://perlbrew.pl/). When using perlbrew I do not use the DBI module of the system perl. I just install it with `cpanm DBI`. Could you try with perlbrew? It would be interesting to see if you get the same error – Håkon Hægland Feb 24 '21 at 06:23
  • Btw, when I run the test for DBD::Oracle I get *"Can't connect to an Oracle instance. Without a database connection, most of DBD::Oracle's test suite will be skipped."* Do you need to set up a database server also? (I have to admit I have never used Oracle database) According to [this](https://medium.com/@pranay.urkude/how-to-setup-oracle-database-on-macos-3c156ceb5565) blog post Oracle does not support macOS, and you need to setup a server using a docker container. – Håkon Hægland Feb 24 '21 at 06:31
  • I only need `DBD::Oracle` to fetch records from a remote Oracle Database. I don't care for the database connection errors during the tests. – h q Feb 24 '21 at 07:18
  • It works with [Homebrew Perl](https://formulae.brew.sh/formula/perl). Thank you Håkon! – h q Feb 24 '21 at 10:35