Installing CPAN module DBD::mysql on macOS Sonoma fails with "symbol not found."

94 views Asked by At

I have a tool, expandfile, written in Perl, that can iterate over rows from an SQL query.

After upgrading to Sonoma, expandfile still worked, using Perl 5.30. I dumped my MySQL database to a text file.

Then I stupidly typed "brew update ImageMagick" and lots of programs were upgraded, including Perl and MySQL. I am having trouble getting expandfile to access SQL.

I updated my environment vars to change PERL5LIB to refer to the new version of Perl, 5.38.2. (I checked and $ARCHFLAGS from Ventura was still "-arch arm64" on this M2 Air.)

Homebrew installed MySQL Server version 8.3.0, so I configured MySQL, reloaded my dump, and set up '.my.cnf'. Data came back fine, as expected... checked from the command line tool.

Then I typed "expandfile" and got the error that Perl module LWP was missing (as were all other CPAN modules). This is what I expected: I always have to re-install CPAN modules after major macOS upgrades. (I did 'sudo -H cpan' and got a message that I had to execute 'o conf init pushy_https', so I did, and 'o conf commit'.) Then I did a long sequence of 'sudo -H cpanm install xxx' to reinstall about 40 CPAN modules. (A few CPAN modules had install errors due to missing prerequisites, fixed.)

I always do DBI and DBD::mysql last, because extra configuration is needed and sometimes there are problems. When I did "sudo -H cpanm install DBD::mysql" I got the message:

installing DBD::mysql failed installing DBD::mysql
DVEEDEN/DBD-mysql-5.004.tar.gz : writemakefile NO '/opt/homebrew/Cellar/perl/5.38.2_1/bin/perl Makefile.PL --testuser=root --testpass=xxx' returned status 512

I looked in .cpanm/work/number.number and found the build log for DBD::mysql. It got as far as {:Running Makefile.PL:} and failed with "Can't link/include C library 'zstd', 'ssl', 'crypto', aborting." Never saw this before.

I tried setting some configure-args: sudo cpanm --configure-args="--libs='-L/opt/homebrew/Cellar/openssl@3/3.2.1/lib -L/opt/homebrew/Cellar/zstd/1.5.5/lib'" install DBD::mysql

That got further, but still fails. The log has 269 warnings about macros, and then finally says "compilation failed, bailout called"

Failed test 'use DBD::mysql;'
at t/00base.t line 15.
Tried to use 'DBD::mysql'.
Error:  Can't load '...mysql.bundle' for module DBD::mysql: dlopen(../blib/arch/auto/DBD/mysql/mysql.bundle, 0x0002):
symbol not found in flat namespace '_mysql_affected_rows' at /opt/homebrew/opt/perl/lib/perl5/5.38/darwin-thread-multi-2level/DynaLoader.pm line 210. at t/00base.t line 15.

I must have missed a step somewhere.. but I thought I did the same steps that worked last time. Do I need something else in configure-args?

1

There are 1 answers

0
THVV On

Thanks to @Håkon’s comment,
I restarted, and then executed

sudo cpanm --configure-args="--libs='-L/opt/homebrew/Cellar/openssl\@3/3.2.1/lib -L/opt/homebrew/Cellar/zstd/1.5.5/lib -L/opt/homebrew/Cellar/mysql/8.3.0_1/lib -lmysqlclient -L/opt/homebrew/Cellar/zstd/1.5.5/lib -lssl -lcrypto -lz -lzstd -lresolv'" install DBD::mysql

It succeeded.