M1 Mac loading X86 libraries - local lightning (opcache, xdebug, imagick)

Bug Summary

PHP extensions (opcache.so, xdebug.so, and imagick.so) are compiled for the x86_64 not for ARM processors.

Summarize the issue in one to two sentences.

Steps to reproduce

Use an M series Apple computer, start local, start a site, and open the site shell.
Run wp cli plugin list or any other wp cli command

See the following warnings:
The wpcli command will execute but always show warnings as long as you don’t use the libraries that are not loading.

See below.

As precisely as you can, list the steps it takes to reliably reproduce the issue.

Environment Info

Describe your environment.

  • What Operating System are you using? OSX Sonomoa 14.3.1
  • What versions of site software (Nginx, Apache, PHP, MySQL) is used?
    Nginx or Apache, PHP 8.2, Mysql 8
  • What version of Local is installed?
    Version 8.3.1+6650 (this was a problem on the previous 8.2.x version as well (and earlier if you see the forums)

Supporting info

Please provide your Local Log. See this Community Forum post for instructions on how to do so:
Failed loading /Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/opcache.so: dlopen(/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/opcache.so, 0x0009): tried: ‘/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/opcache.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’)), ‘/System/Volumes/Preboot/Cryptexes/OS/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/opcache.so’ (no such file), ‘/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/opcache.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’))
Failed loading /Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/xdebug.so: dlopen(/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/xdebug.so, 0x0009): tried: ‘/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/xdebug.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’)), ‘/System/Volumes/Preboot/Cryptexes/OS/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/xdebug.so’ (no such file), ‘/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/xdebug.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’))

Warning: PHP Startup: Unable to load dynamic library ‘/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so’ (tried: /Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so (dlopen(/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so, 0x0009): tried: ‘/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’)), ‘/System/Volumes/Preboot/Cryptexes/OS/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so’ (no such file), ‘/Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’))), /opt/homebrew/Cellar/php/8.3.2/lib/php/20230831//Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so.so (dlopen(/opt/homebrew/Cellar/php/8.3.2/lib/php/20230831//Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so.so, 0x0009): tried: ‘/opt/homebrew/Cellar/php/8.3.2/lib/php/20230831//Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so.so’ (no such file), ‘/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/php/8.3.2/lib/php/20230831//Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so.so’ (no such file), ‘/opt/homebrew/Cellar/php/8.3.2/lib/php/20230831//Users/username/Library/Application Support/Local/lightning-services/php-8.2.10+1/bin/darwin/lib/php/extensions/no-debug-non-zts-20220829/imagick.so.so’ (no such file))) in Unknown on line 0

Include any screenshots or video recordings of the issue to help others reproduce.

Hi @sebastian

Are you using the Apple Silicon build for Local? If so do you have Rosetta installed?

Hi @Nick-B thanks for getting back to me. Just to make sure I downloaded the latest version for apple silicon. (Maybe I downloaded the wrong version at some point?)
I do have rosetta installed (this should always be an automatic process but I checked).

And I no longer see the same error message, but a new one:

Failed loading /Users/my_username/Library/Application Support/Local/lightning-services/php-8.1.23+0/bin/darwin-arm64/lib/php/extensions/no-debug-non-zts-20210902/xdebug.so: dlopen(/Users/my_username/Library/Application Support/Local/lightning-services/php-8.1.23+0/bin/darwin-arm64/lib/php/extensions/no-debug-non-zts-20210902/xdebug.so, 0x0009): symbol not found in flat namespace ‘__zend_get_parameters_array_ex’

Warning: PHP Startup: imagick: Unable to initialize module
Module compiled with module API=20210902
PHP compiled with module API=20230831
These options need to match
in Unknown on line 0

I’m searching the forums here and see some others who have run into the same error. One of our Devs provided some additional information and troubleshooting steps here:

Thanks @Nick-B I did read through that, but that doesn’t really solve the issue. What I don’t know is what ‘might’ be overriding the local path. I can certainly share my path and other variable to troubleshoot.

I di noticed that this does not matter if I have apache of nginx installed, however switching versions of PHP does seem to make a difference.

With php 8.2.10 I get the following updated error message:

Zend OPcache requires Zend Engine API version 420220829.
The Zend Engine API version 420230831 which is installed, is newer.
Contact Zend Technologies at http://www.zend.com/ for a later version of Zend OPcache.

Xdebug requires Zend Engine API version 420220829.
The Zend Engine API version 420230831 which is installed, is newer.
Contact Derick Rethans at Xdebug: Documentation » FAQ for a later version of Xdebug.

Warning: PHP Startup: imagick: Unable to initialize module
Module compiled with module API=20220829
PHP compiled with module API=20230831
These options need to match
in Unknown on line 0

Which seems to be only a problem with imagick…?

I should add that using php 8.3.0 removes that problem altogether! The only output to ‘wp plugin list’ is now:
Cannot load Zend OPcache - it was already loaded

While that is good news, it does not (necc) allow me to error free test older versions of php for troubleshooting… Milage may vary of course.

EDIT: I can add that this error appears also in php 8.0.x

1 Like

Hi @sebastian

I’m on an M3 mac using Sonoma but I haven’t been able to replicate this so far.

To clarify this issue appears when you have PHP 8.2.10 or 8.0.x set but not in 8.3.0? And you’re just running any WP-CLI command in the Site Shell?

If you’re still running into trouble could you share your full local log here for us? Please click the Download Local Logs button from the Support tab in Local. This will generate a zip archive that contains the Local log along with some other diagnostic information to help quickly zero in on any issues that Local is encountering.

Hi @Nick-B,

that is correct. running any version prior to 8.3.x shows a php failure for opcache.so and xdebug.so (and imagick) - Looks like they are not compiled with the same version – according to the ourtput) Any wp command will show the notice/warning/error. The command will run IF its not impacted, otherwise just fail with a php error.

Here is my zipped log:
local-logs.zip (733.6 KB)

Can you share a screenshot of what you see when you click on Open Site Shell? Just at the top of your shell it should give a readout like this:

Setting Local environment variables...
----
WP-CLI:   WP-CLI 2.9.0
Composer: 2.6.2 2023-09-03
PHP:      8.2.10
MySQL:    mysql  Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)
----
Launching shell: /bin/zsh ...

Here you go:

Thanks for sharing your shell output, @sebastian.

Just to make sure I downloaded the latest version for apple silicon. (Maybe I downloaded the wrong version at some point?)

Downloading the Intel version of Local, running it on an Apple Silicon Mac, then later installing the Apple Silicon version could explain the messages you have about x86_64 versions of PHP extensions such as opcache.so and xdebug.so. Those versions would have been installed by the original Intel version of Local and could still be on your system.

To fix it you can try these steps:

  1. Confirm the current version of Local you have installed is the Apple Silicon build. To be sure, open a terminal and run this:

    file /Applications/Local.app/Contents/MacOS/Local
    

    You should see a line ending in ‘arm64’:

    /Applications/Local.app/Contents/MacOS/Local: Mach-O 64-bit executable arm64
    

    If you see x86_64 instead of arm64, download and install the latest Apple Silicon version from Releases - Local before you continue.

  2. Stop your sites and close Local if it’s running.

  3. In the Finder, choose Go → Go to Folder.

  4. Enter ~/Library/Application Support/Local/lightning-services/ and press enter.

  5. In the Finder window that opens, delete all folders with a php- prefix, as well as the mailpit-1.12.1+0 folder (you might have the old Intel binary for that too):

  6. Launch Local. It will see that PHP and mailpit are missing, and copy the Apple Silicon versions of PHP 8.1.23 (and Mailpit) to the lightning-services folder you were just looking at.

  7. Click one of your sites.

    • If it was using PHP 8.1.23, toggle it to another version to download that version, then back to PHP 8.1.23. You should be able to start the site as normal and open the site shell without seeing warnings.
    • If it was using another version of PHP, there should be a banner at the top of the window saying “Missing PHP 8.2”. When you start this site, Local will download the Apple Silicon PHP version to replace the old version you had with Intel libraries.
    • You can optionally toggle an existing site between different PHP versions to force Local to download the Apple Silicon binaries and libraries for other PHP versions.

This process replaces the Intel versions of PHP and libraries like imagick.so you may have installed accidentally by downloading the Intel version (or that could have come from a full disk restore from a previous Intel Mac, for example) with the Apple Silicon versions, and should remove the errors you saw.

1 Like

Hi @nickc
Thanks for the instrcutions. Yes, I am on the ARM version of Local.

Did all of that and reinstalled them by launching finder, it reinstalled php 8.1.xxx
I selected php 8.2., local downloaded and installed it. I switched back to php 8.1.x and launched the shell.

Ran a wp plugin list:
Setting Local environment variables…

WP-CLI: WP-CLI 2.9.0
Composer: 2.6.2 2023-09-03
PHP: 8.1.23
MySQL: mysql Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)

Launching shell: /bin/zsh …
   ~/Local Sites/client1com/app/public  wp plugin list  :heavy_check_mark:
Failed loading /Users/username/Library/Application Support/Local/lightning-services/php-8.1.23+0/bin/darwin-arm64/lib/php/extensions/no-debug-non-zts-20210902/xdebug.so: dlopen(/Users/username/Library/Application Support/Local/lightning-services/php-8.1.23+0/bin/darwin-arm64/lib/php/extensions/no-debug-non-zts-20210902/xdebug.so, 0x0009): symbol not found in flat namespace ‘__zend_get_parameters_array_ex’

Warning: PHP Startup: imagick: Unable to initialize module
Module compiled with module API=20210902
PHP compiled with module API=20230831
These options need to match
in Unknown on line 0
±----------------------------±---------±----------±--------+
| name | status | update | version |
±----------------------------±---------±----------±--------+
| advanced-custom-fields | active | none | 6.2.7 |

As you can see while it runs it still shows errors (warnigns really) although with the arm versions of imagick and xdebug (possibly - i dont know how to verify that those are actually compiled for ARM)

When using PHP 8.2.x I get this warning about an non-matching Zend engine version:

Xdebug requires Zend Engine API version 420220829.
The Zend Engine API version 420230831 which is installed, is newer.
Contact Derick Rethans at Xdebug: Documentation » FAQ for a later version of Xdebug.

Warning: PHP Startup: imagick: Unable to initialize module
Module compiled with module API=20220829
PHP compiled with module API=20230831
These options need to match
in Unknown on line 0

I should say that in both version at least I get the output for a WP command that I ran, so that’s a huge improvement. If Im correct imagick replaces DG image lib (can’t recall ATM), so does it fall back on that?

Thanks for trying those steps, @sebastian — good to see they cleared the warnings about incompatible libraries.

The remaining “symbol not found in flat namespace” error you see doesn’t seem related to processor architecture any more. It suggests the opcache.so extension Local bundles is being loaded by a newer version of PHP than the one Local is using for that site.

You might see the warning (and the Zend one) if you had a global version of PHP installed (via homebrew, for example), or perhaps a global version of PHP pulled in as a dependency for a copy of WP-CLI installed via homebrew, or maybe a language version manager like phpenv.

I can’t reproduce the error on a fresh system with Local’s PHP 8.1.23, so it might be worth temporarily uninstalling global versions of PHP, WP-CLI, or phpenv in case you’ve added any of those on your system. You’d need to restart your terminal after those changes before retesting with Local. Typing which php after opening Local’s shell might give you clues about the path to any global versions of PHP overriding Local’s version, but you could also temporarily uninstall global versions anyway even if that path shows the one to Local’s PHP.