简体   繁体   中英

El Capitan perl DBD unsafe use of relative path

I encountered the following error while trying to run a perl script that uses DBI after upgrading to El Capitan (typical!):

install_driver(mysql) failed: Can't load '/Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle, 1): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
Reason: unsafe use of relative rpath libmysqlclient.18.dylib in /Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle with restricted binary at /System/Library/Perl/5.18/darwin-thread-multi-2level/DynaLoader.pm line 194.

After seeing a solution posted for a similar problem in python here I have posted the same solution for Perl below.

El Capitan's system integrity protection prevents programs in protected locations (in this case /usr) from calling a shared library that uses a relative reference to another shared library. The following solved it for me. Note, my mysql is installed via brew.

sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/Cellar/mysql/5.6.26/lib/libmysqlclient.18.dylib /Library/Perl/5.18/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle

You can also install mysql, or its open source alternative mariadb, with the "brew" tool. This avoids giving the above issue on El Capitan

$ brew install mysql

or

$ brew install mariadb

You can find brew at http://brew.sh/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM