Problem with WP CLI

Issue Summary

When trying to run the wp post create wp-cli command in my local Site Shell I get the following error:

Fatal error: Cannot declare class WP_CLI, because the name is already in use in phar:///Applications/ on line 26

I have checked and I don’t have any other install of wp cli on my local. When I run wp --info I get:

OS:	Darwin 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64 x86_64
Shell:	/usr/local/bin/zsh
PHP binary:	/Users/etienne/Library/Application Support/Local/lightning-services/php-8.0.0+2/bin/darwin/bin/php
PHP version:	8.0.0
php.ini used:	/Users/etienne/Library/Application Support/Local/run/wL7PYIX6z/conf/php/php.ini
MySQL binary:	/Users/etienne/Library/Application Support/Local/lightning-services/mysql-5.7.28+5/bin/darwin/bin/mysql
MySQL version:	mysql  Ver 14.14 Distrib 5.7.28, for macos10.14 (x86_64) using  EditLine wrapper
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/Users/etienne/Desktop/Studio DPE/Clients/WOW/Les Bottés/Local/app/public
WP-CLI packages dir:	
WP-CLI global config:	/Applications/
WP-CLI project config:	
WP-CLI version:	2.5.0

I have even tried updating the wp-cli.phar but it doesn’t solve the issue.

Troubleshooting Questions

  • Does this happen for all sites in Local, or just one in particular?
    On all websites

System Details

  • Which version of Local is being used?

  • What Operating System (OS) and OS version is being used?
    macOS Monterey 12.2.1

  • Local Logs (222.1 KB)

Hello @epigeyre

Could you please suggest, how you fixed the above issue? I am facing the same problem after updating my system.

Thanks in advance!

I had the exact same problem, though it intermittently worked. I fixed it by disabling the opcache for cli (which is the PHP default anyway).

Make sure your site is stopped. In Local select your site and click “Go to site folder”, navigate to conf\php, and edit php.ini.hbs to comment out the opcache.enable_cli line

; opcache.enable_cli=1

Start the site to regenerate the php.ini

Should work from now on

Hello @ankitguptaindia,

I didn’t found any solution, I just ended up not using WP CLI for what I wanted to do. However, I’ve just tested @dave_slaughter solution and it works perfectly for me :).


Hey @dave_slaughter

Thanks for the solution. It fixed my WP CLI problem. You are Great :tada:

Thanks for the response @epigeyre ! Yes, that fixed my problem too.

Hi! I stumbled on the same problem after updating to version 6.4.1 today.

This workaround with disabling the opcache for CLI worked for me too.

Still would like to know why this is no longer working normally anymore, especially after updates.


Hi @ankitguptaindia @epigeyre @dave_slaughter;

Contrary to what I wrote just minutes ago, I did find another solution.

I recently had another issue with the site being very slow, and managed to get it working normally again by changing some other things, see:

In the second part of that message I also made additions to the way wp-cli starts (I think):

php "%~dp0\..\wp-cli.phar" %*


php -dxdebug.mode=debug "%~dp0\..\wp-cli.phar" %*

For me the shell works without disabling the opcache.enable_cli=1 line

Hope this helps,


The problem still persists with version 6.4.2.

Current workaround:

The locations for these 2 batch files are:

  1. /Users/{username}/Appdata/Local/Programs/Local/resources/extraResources/bin/wp-cli/win32/wp.bat
  2. /Users/{username}/Appdata/Local/Programs/Local/resources/extraResources/bin/composer/win32/composer.bat

The changes are to add -dxdebug.mode=debug like in this example:

The other issue (LocalWP app itself is no longer able to retrieve the WP version from the site) seems fixed at this time.

php -dxdebug.mode=debug “%~dp0…\wp-cli.phar” %*

The problem still persists with version 6.4.3.

The workaround for version 6.4.2 works

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.