1

I'm having trouble with a Perl application that fails with an LibXSLT-related error on Mac OS Big Sur 11.4 on multiple computers (all Intel Macs) - it worked correctly before the Mac OS upgrade, and now seems to fail on a freshly installed up-to date Mac.

The error message for a minimal script perl -MXML::LibXSLT -E 'say $INC{"XML/LibXSLT.pm"}' (using system perl - no other perl is installed on the machine) is as follows:

Can't load '/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/XML/LibXSLT/LibXSLT.bundle' for module XML::LibXSLT: dlopen(/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/XML/LibXSLT/LibXSLT.bundle, 0x0001): symbol '_xsltLibxsltVersion' not found, expected in flat namespace by '/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/XML/LibXSLT/LibXSLT.bundle' at /System/Library/Perl/5.30/darwin-thread-multi-2level/DynaLoader.pm line 197. at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/XML/LibXSLT.pm line 48. BEGIN failed--compilation aborted at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/XML/LibXSLT.pm line 48. Compilation failed in require. BEGIN failed--compilation aborted.

cpan -i XML::LibXSLT confirms that XML::LibXSLT is up to date (1.99).

I tried updating the xslt libraries with brew install libxslt but it did not seem to make any difference.

I've tried running brew link libxslt --force, which now does not do anything (Warning: Refusing to link macOS provided/shadowed software: libxslt).

Running cpan -f -t XML::LibXSLT fails with the following error message:

looking for -lxslt... no
libxslt not found
Try setting LIBS and INC values on the command line

If I set the LIBS and INC values to the path suggested by brew export LIBS="-L/usr/local/opt/libxslt/lib" and export INC="-I/usr/local/opt/libxslt/include", it still fails with this error.

Any suggestions on how to debug this? I'm not a Perl developer, just trying to run an existing app.

Peteris
  • 3,281
  • 2
  • 25
  • 40
  • Out of curiosity, does `cpan -f -t XML::LibXSLT` run successfully? – ikegami Jun 09 '21 at 16:02
  • The module install fine here. macOS 11.2.3, perlbrew perl version 5.32.0. Are you using the system perl? – Håkon Hægland Jun 09 '21 at 17:14
  • *"Can't load '/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/XML/LibXSLT/LibXSLT.bundle' for module XML::LibXSLT"* : Is this an error you get when running `cpan XML::LibXSLT` or is it coming from a script that uses the module? – Håkon Hægland Jun 09 '21 at 17:16
  • Is this an M1 or an intel Mac? – Håkon Hægland Jun 09 '21 at 17:19
  • @HåkonHægland yes, it's using the system perl, nothing else is installed. – Peteris Jun 09 '21 at 19:40
  • @ikegami it does not, I edited to add the errors regarding this. – Peteris Jun 09 '21 at 19:51
  • @HåkonHægland also, I believe that this problem wasn't an issue on macOS 11.2.3, it's something specific to recent macOS changes. Everything worked on the same machine before the latest OS upgrade; I have installed and run the same script earlier on multiple computers, on earlier macOS versions it worked without non-system perl or anything else unusual. I don't have any macs available now with an older macOS version to verify, but I replicated this on another clean mac (didn't have anything perl- or xml-related installed ever, only apple devtools) with 11.4 which has the exact same errors. – Peteris Jun 09 '21 at 20:13
  • I tried with the system perl now. I first installed `cpanm` with `sudo cpan App::cpanminus`, then tried `sudo cpanm XML::LibXSLT` and it failed with `looking for -lxslt... libxslt not found. Try setting LIBS and INC values on the command line` But the strange thing is that if I run it again it says `XML::LibXSLT is up to date. (1.99)`. So there might also be a bug in `cpan` and `cpanm` here.. Can you try with perlbrew? – Håkon Hægland Jun 10 '21 at 05:05
  • Added [bug report](https://github.com/miyagawa/cpanminus/issues/628) – Håkon Hægland Jun 10 '21 at 06:56
  • Can you update your question with the minimal script that produces the error? When I uses the system perl (with the preinstalled XML::LibXSLT) the following script for example runs fine here: `perl -MXML::LibXSLT -E 'say $INC{"XML/LibXSLT.pm"}'`. Does this one-liner give you the same error? – Håkon Hægland Jun 10 '21 at 18:11
  • 1
    @HåkonHægland yes, that one-liner is a good minimal example, it does give the same error with system perl on both 11.4 macs that I have available at the moment. I updated the question with it. – Peteris Jun 10 '21 at 19:34
  • What output do you get when running the command `pkg-config --debug libxslt` ? [Here](https://pastebin.com/1SvqR8Nr) is the output I get. – Håkon Hægland Jun 10 '21 at 20:24
  • @HåkonHægland I think I'm getting the exact same output https://pastebin.com/WzCXatvN from the 'fresh' mac; the recently updated one (https://pastebin.com/X26QRx1v) has slightly different paths for the commandline tools SDK. – Peteris Jun 10 '21 at 20:35
  • Yes it is exactly the same result as I get, very strange that the script works for me and not for you then.. I think I will have to update my mac to 11.4 to check more what is going on. – Håkon Hægland Jun 10 '21 at 20:46
  • Added [bug report](https://developer.apple.com/forums/thread/682584) – Håkon Hægland Jun 12 '21 at 08:53

1 Answers1

2

Perlbrew

Eventually, I succeeded with perlbrew instead of the default OS X system perl.

The following process worked, based on recommendations at https://perlbrew.pl :

curl -L https://install.perlbrew.pl | bash   
source ~/perl5/perlbrew/etc/bashrc
perlbrew install perl-5.16.0   
perlbrew switch perl-5.16.0
sudo cpan -i XML::LibXSLT

I consider it not as a proper solution but as a workaround - after all, there's no reason why the OS X preinstalled libxslt shouldn't just work with the preinstalled system perl - but it at least works.

Peteris
  • 3,281
  • 2
  • 25
  • 40
  • Great that you made it work. I will have a look at the issue with the system perl later. Note that you do not need to use (and should not use) `sudo` with the perlbrew perl. And perl version 5.16 is nine years old, I would have used one of the newest versions 5.34 or 5.32. – Håkon Hægland Jun 10 '21 at 17:08
  • @HåkonHægland well, https://perlbrew.pl/ still lists 5.16 as "latest stable release" :) – Peteris Jun 10 '21 at 19:26
  • Yes that is not good. Probably they just forgot to update that part. I will notify them. – Håkon Hægland Jun 10 '21 at 19:30
  • [Here](https://www.cpan.org/src/) is a list of the stable releases – Håkon Hægland Jun 10 '21 at 19:32
  • *"perlbrew.pl still lists 5.16 as latest stable release"* : Added a [comment](https://github.com/gugod/App-perlbrew/issues/726) about this.. – Håkon Hægland Jun 10 '21 at 20:01