Local Community

Unable to use WP-CLI

I understand to use WP-CLI with a WordPress site in Local you right-click the site and click “Open site shell”.

When I do this, this is the output I get:

❯ /Users/alec/Library/Application\ Support/Local/ssh-entry/u0K5N7gSI.sh; exit
-n -e
Setting Local environment variables...
----
WP-CLI:   WP-CLI 2.6.0
Composer: 2.1.5 2021-07-23
PHP:      8.0.0
MySQL:    mysql  Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)
----
Launching shell: /opt/homebrew/bin/zsh ...

That’s fine, but the wp command is not available:

❯ wp --version
zsh: command not found: wp

Why can’t I use WP-CLI? Does your integration not support Zsh or something?

Hi there, @alec! Thank you for bringing your question to the Local Community! :wave:

I spun up a new site with the same settings you have here (PHP 8.0.0 & MySQL 8.0.16) and when I use the command wp --version I get WP-CLI 2.6.0 returned.

Shared with CloudApp

If you start up a brand new site do you still experience this?

Let me know!

:woman_technologist:t3: Sam

Thanks for your reply @sammunoz.

I’ve tested this on two other Local sites (same result) and just tried creating a fresh site with the same result also:

/Users/alec/Library/Application\ Support/Local/ssh-entry/oSXZBuYAw.sh; exit
-n -e
Setting Local environment variables...
----
WP-CLI:   WP-CLI 2.6.0
Composer: 2.1.5 2021-07-23
PHP:      8.0.0
MySQL:    mysql  Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)
----
Launching shell: /opt/homebrew/bin/zsh ...

test/app/public via 🐘 v8.1.7
❯ wp --version
zsh: command not found: wp

Is “Open site shell” supposed to SSH into the Docker container that runs the site? If so this doesn’t seem to be happening.

Some more info about my shell setup:

  • iTerm 2
  • asdf
  • Homebrew
  • Zsh

The full setup can be found on my dotfiles.

Hi there, @alec!

Thank you for that information - it appears that this is a known bug with Zsh in PHP 8.0.

It was fixed in PHP 7.4 but then resurfaced with 8.0 (see this thread for more information): Local Lightning PHP 8 "Open Site Shell" does not work on ZSH - #2 by tlock

You may want to try switching to PHP 7.4 or 7.3 and seeing if that works for you!

Let me know if that helps,

:woman_technologist:t3: Sam

Thanks Sam, I’ll follow that other topic in the hope this gets fixed.

1 Like

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

Sounds great @alec - if you have any other questions, please do not hesitate to reach out!

Sam :woman_technologist:t3: