PHP PECL module install fix Warning: mkdir(): File exists in System.php
I wanted to install imagick (Image Magick) pecl module on my local machine.
I've tried with
$ pecl install imagick
but I got the following error
Build process completed successfully
Installing '/opt/homebrew/Cellar/[email protected]/8.1.29/include/php/ext/imagick/php_imagick_shared.h'
Installing '/opt/homebrew/Cellar/[email protected]/8.1.29/pecl/20210902/imagick.so'
Warning: mkdir(): File exists in System.php on line 294
PHP Warning: mkdir(): File exists in /opt/homebrew/Cellar/[email protected]/8.1.29/share/[email protected]/pear/System.php on line 294
Warning: mkdir(): File exists in /opt/homebrew/Cellar/[email protected]/8.1.29/share/[email protected]/pear/System.php on line 294
ERROR: failed to mkdir /opt/homebrew/Cellar/[email protected]/8.1.29/pecl/20210902
The solution
The issue was that /opt/homebrew/Cellar/[email protected]/8.1.29/pecl
is a symlink to a non-existent directory - /opt/homebrew/lib/php/pecl
To fix it, create the directory
$ mkdir /opt/homebrew/lib/php/pecl/
This is on Mac but I'm assuming Windows and Linux solutions are the same.