Local Community

Win32: WP-CLI: Warning: PHP Startup: Unable to load dynamic library ‘php_imagick.dll’

Bug Summary

On windows, opening a site shell results in a bunch of "Unable to load dynamic library ‘php_imagick.dll’ " warnings to be printed. This happens both with the “command prompt” and “git bash” terminal setting.

See also:

Steps to reproduce

Simply open a site shell on Windows and observe the warnings.
This happens both with the “command prompt” and “git bash” terminal setting.

Environment Info

Describe your environment.

For me this happens on Windows 10 using Local 6.2.0+5679 with at least PHP 7.4.1
I have not tested other PHP versions but due to the nature of how ImageMagick and the imagick PHP extension are included in the package I have no doubt those are going to suffer from similar if not identical bugs.

Other environments described in the provided community threads above.

How to fix

There’s a couple of things in %APPDATA%\Local\lightning-services\php-7.4.1+16\lib\PhpService.js that can be improved regarding how ImageMagick paths are handled. Complete file attached. Patch for quick review below.

PhpService.zip (2.5 KB)

--- <unnamed>
+++ <unnamed>
@@ -87,13 +87,15 @@
     get siteShellStartupBat() {
-        return `\nSET PATH=${path_1.default.join(this.$PATH, 'ImageMagick')};%PATH%\n`;
+        return `\nSET PATH=${path_1.default.join(this.$PATH, 'ImageMagick', 'bin')};%PATH%\n`;
     get siteShellStartupPOSIX() {
         let shellStartup = `\nexport MAGICK_CODER_MODULE_PATH="${this.imageMagickCodersDir}"\n`;
         switch (os_1.default.platform()) {
             case 'linux':
                 shellStartup += `\nexport LD_LIBRARY_PATH="${path_1.default.join(__dirname, '../bin', 'linux', 'shared-libs')}"\n`;
+            case 'win32':
+                shellStartup += `\nexport PATH="${this.toPOSIX(this.imageMagickBinDir)}:$PATH\"n`;
         return shellStartup;
@@ -115,13 +117,38 @@
+     * This probably has an importable helper somewhere but no idea how to import it here
+     */
+     toPOSIX(t) {
+        let e = t.replace(/\\/g, "/"),
+            r = !1;
+        if ("win32" === os_1.default.platform()) {
+            0 === t.indexOf("\\\\") && (r = !0), 1 === t.indexOf(":") && (e = e.replace(":", ""));
+            const a = e.split("/").filter((t) => t);
+            1 === a[0].length && (a[0] = a[0].toLowerCase()), (e = "/" + a.join("/")), r && (e = "/" + e);
+        }
+        return e;
+    }
+    /**
      * Coders directory required by ImageMagick
+    get imageMagickBinDir() {
+        if (os_1.default.platform() === 'win32' && !Local.isWindows32Bit()) {
+            return path_1.default.join(__dirname, '../bin', 'win64', 'ImageMagick', 'bin');
+        }
+        return path_1.default.join(__dirname, '../bin', os_1.default.platform(), 'ImageMagick', 'bin');
+    }
     get imageMagickCodersDir() {
+        if (os_1.default.platform() === 'win32' && !Local.isWindows32Bit()) {
+            return path_1.default.join(__dirname, '../bin', 'win64', 'ImageMagick', 'modules-Q16', 'coders');
+        }
         return path_1.default.join(__dirname, '../bin', os_1.default.platform(), 'ImageMagick', 'modules-Q16', 'coders');
     get ghostscriptLib() {
         // GS_LIB env variable in fpm www config
+        if (os_1.default.platform() === 'win32' && !Local.isWindows32Bit()) {
+            return path_1.default.join(__dirname, '../bin', 'win64', 'ghostscript', 'Resource', 'Init');
+        }
         return path_1.default.join(__dirname, '../bin', os_1.default.platform(), 'ghostscript', 'Resource', 'Init');
     get lightningServicePlatform() {

Hi Dieterv,

Thanks for this information.

I tested your solution and after finding the place the PhpService.js file needs to go I got a positive result when opening a Bash shell from Local :+1:

My location for the PhpService.js was slightly different and could be found at:


Another question which came to mind; the ImageMagick Coders directory does this allows come pre-installed with either Win10, or Local itself?

Thanks again,

Hi Ruud,

Looks like there might be slight variations in the exact location %APPDATA% expands to. I guess %USERPROFILE%\AppData\Roaming\Local\lightning-services\php-7.4.1+16\lib\PhpService.js would probably be more correct then :slight_smile:

I don’t understand your other question, but the way things are set up in PhpService.js the MAGICK_CODER_MODULE_PATH variable locks the path where ImageMagick can locate its coder modules to the %USERPROFILE%\AppData\Roaming\Local\lightning-services\php-7.4.1+16\bin\win64\ImageMagick\modules-Q16\coders\ directory. So that would be the version that comes with LocalWP. This directory does not actually exist in my LocalWP installation though.

Thanks for your reply which helped me find the ImageMagick directory too.
Mine does also not have a modules-Q16\coders directory.

I checked this error and its still around.

Local 6.4.0 has a warning on PHP startup. The CLI is fixed by this code but not the WordPress Version area inside the UI.

Does anyone know why the Local team have not fixed this?


I think that recently my PHP 7.4.1 setup got updated to version PHP7.4.1+18 (instead of +16)

This triggered the return of the issues with the missing imagick.dll

On the location we patched the PhpService.js before there was no php-7.4.1+18 folder but instead it had moved to a new location =>


After merging in the changes from the 7.4.1+16 version it worked again.

Hopes this helps!

1 Like