无法在 macOS Big Sur 上安装 DBD::Oracle => 找不到相关的 dylib '@rpath/libclntsh.dylib.19.1'

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

我无法在 macOS Big Sur 11.2.1 上构建和安装 Oracle Instant Client 19.8。我收到以下错误:

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.

Big Sur 似乎没有将 DYLD_LIBRARY_PATH 环境变量传递给子 shell:

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.

我试过:

但我似乎无法弄清楚。非常感谢您的帮助。转载:

  1. 安装 Oracle Instant Client 19.8/opt/instantclient_19_8

  2. macOS Big Sur,设置必要的环境变量。

% 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

这是我的第一个问题。 DYLD_LIBRARY_PATH 已清除。

  1. 安装 cpanm 到 ~/.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. 强制安装DBI,以避免与内置版本发生任何冲突:
% 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. 安装 DBD::Oracle - 总是失败。
% 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

问题是 DYLD_LIBRARY_PATH 环境变量在 运行 宁 make test 时没有传播到 perl,如 here 所述。代替 运行ning cpanm DBD::Oracle,您可以使用例如手动下载模块 运行 测试。 prove。以下对我有用(macOS BigSur 11.2.1),perlbrew perl 版本 5.32.0:

  • https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html

    下载并安装 instantclient-basic-macos.x64-19.8.0.0.0dbru.dmginstantclient-sdk-macos.x64-19.8.0.0.0dbru.dmg
  • 安装DBD::Oracle(不带运行宁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
    

注意事项: