0

I did a brew upgrade I have php 8.1 on osx 12.x

Imagick is not working

PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/pecl/20210902/imagick.so (dlopen(/usr/local/lib/php/pecl/20210902/imagick.so, 0x0009): tried: '/usr/local/lib/php/pecl/20210902/imagick.so' (no such file), '/usr/local/lib/imagick.so' (no such file), '/usr/lib/imagick.so' (no such file)), /usr/local/lib/php/pecl/20210902/imagick.so.so (dlopen(/usr/local/lib/php/pecl/20210902/imagick.so.so, 0x0009): tried: '/usr/local/lib/php/pecl/20210902/imagick.so.so' (no such file), '/usr/local/lib/imagick.so.so' (no such file), '/usr/lib/imagick.so.so' (no such file))) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/pecl/20210902/imagick.so (dlopen(/usr/local/lib/php/pecl/20210902/imagick.so, 0x0009): tried: '/usr/local/lib/php/pecl/20210902/imagick.so' (no such file), '/usr/local/lib/imagick.so' (no such file), '/usr/lib/imagick.so' (no such file)), /usr/local/lib/php/pecl/20210902/imagick.so.so (dlopen(/usr/local/lib/php/pecl/20210902/imagick.so.so, 0x0009): tried: '/usr/local/lib/php/pecl/20210902/imagick.so.so' (no such file), '/usr/local/lib/imagick.so.so' (no such file), '/usr/lib/imagick.so.so' (no such file))) in Unknown on line 0
Configuration File (php.ini) Path: /usr/local/etc/php/8.1
Loaded Configuration File:         /usr/local/etc/php/8.1/php.ini
Scan for additional .ini files in: /usr/local/etc/php/8.1/conf.d
Additional .ini files parsed:      /usr/local/etc/php/8.1/conf.d/ext-opcache.ini

My thinking is the relevant error is about /usr/local/lib/imagick.so.so and I have a file /usr/local/lib/php/pecl/20210902/imagick.so that might be better to link against.

  • I also noticed that inside my php.ini I got extension="imagick.so" which I renamed extension=imagick.so
  • if I ls /usr/local/lib/php/pecl/20210902/ I get no file now if I ls /usr/local/lib/php/pecl/ then use autocompletion to finish 20210902 I get imagick.so

I tried making a symlink in /usr/local/lib/ but it does not work. What is the way to resolve errors like this?

tried to symlink sudo ln -s /usr/local/lib/php/pecl/20210902/imagick.so /usr/lib/imagick.so but I get operation not permited

$ ls -l /usr/local/lib/php/pecl/20210902/imagick.so /usr/local/lib/imagick.so
ls: /usr/local/lib/php/pecl/20210902/imagick.so: No such file or directory
lrwxr-xr-x  1 user  admin  43 Dec  1 10:58 /usr/local/lib/imagick.so -> /usr/local/lib/php/pecl/20210902/imagick.so
$ ls -l /usr/local/lib/php/pecl/*/imagick.so
-rw-r--r--  1 ed  admin  438784 Jun 16 17:25 /usr/local/lib/php/pecl/20190902/imagick.so

I did What @nohillside suggested below and while this solved the issue I believe there is still an issue related to the same problem

php --ini

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

I try reinstalling by pecl uninstall imagick but I get same error

pecl uninstall imagick
PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/pecl/20210902/imagick.so (dlopen(/usr/local/lib/php/pecl/20210902/imagick.so, 0x0009): Library not loaded: /usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.10.dylib
  Referenced from: /usr/local/lib/php/pecl/20190902/imagick.so
  Reason: tried: '/usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.10.dylib' (no such file), '/usr/local/lib/libMagickWand-7.Q16HDRI.10.dylib' (no such file), '/usr/lib/libMagickWand-7.Q16HDRI.10.dylib' (no such file)), /usr/local/lib/php/pecl/20210902/imagick.so.so (dlopen(/usr/local/lib/php/pecl/20210902/imagick.so.so, 0x0009): tried: '/usr/local/lib/php/pecl/20210902/imagick.so.so' (no such file), '/usr/local/lib/imagick.so.so' (no such file), '/usr/lib/imagick.so.so' (no such file))) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/pecl/20210902/imagick.so (dlopen(/usr/local/lib/php/pecl/20210902/imagick.so, 0x0009): Library not loaded: /usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.10.dylib
  Referenced from: /usr/local/lib/php/pecl/20190902/imagick.so
  Reason: tried: '/usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.10.dylib' (no such file), '/usr/local/lib/libMagickWand-7.Q16HDRI.10.dylib' (no such file), '/usr/lib/libMagickWand-7.Q16HDRI.10.dylib' (no such file)), /usr/local/lib/php/pecl/20210902/imagick.so.so (dlopen(/usr/local/lib/php/pecl/20210902/imagick.so.so, 0x0009): tried: '/usr/local/lib/php/pecl/20210902/imagick.so.so' (no such file), '/usr/local/lib/imagick.so.so' (no such file), '/usr/lib/imagick.so.so' (no such file))) in Unknown on line 0

if I do ls /usr/local/lib/php/pecl/ I get two versions 20190902 20210902

2
  • There seems to be an incompatibility between the installed versions of PHP and imagemagick. Maybe removing/uninstalling everything and reinstalling it is easier than trying to fix this.
    – nohillside
    Commented Dec 1, 2021 at 17:52
  • @nohillside yes I agree this is why I tried to uninstall imagick but as you can see I cannot anymore. pecl uninstall fails. I am not sure how to go about that? I already uninstalled imagemagick with homebrew. how can the uninstaller be broken ? Should I delete files manually ? which files ?
    – AppleBee
    Commented Dec 1, 2021 at 18:31

1 Answer 1

0

Details matter, 20210902 isn't the same as 20190902 :-)

Run

sudo rm /usr/local/lib/imagick.so
sudo ln -s /usr/local/lib/php/pecl/20190902/imagick.so /usr/local/lib/imagick.so
sudo chmod 644 /usr/local/lib/imagick.so
3
  • Your answer solved the issue I believe but also revealed another one; PHP is still confused with those two versions :) I updated the question, let me know if this is unrelated and I will accept your solution as it is.
    – AppleBee
    Commented Dec 1, 2021 at 17:14
  • I cannot uninstall imagick with pecl :) updated the question
    – AppleBee
    Commented Dec 1, 2021 at 17:27
  • to make it work in the end I had to did what you said but with 20290902 after reinstalling everything a million times
    – AppleBee
    Commented Dec 1, 2021 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .