Which version of Local is being used?
Local 5.10.5+5403
What Operating System (OS) and OS version is being used?
macOS Big Sur 11.4, M1 MacBook Air
Issue Summary
wp cli commands not recognized in terminal. Right clicked site in Local site list, chose “Open Site Shell” and attempted to utilize any wp command. Always outputs: zsh: command not found: wp
The terminal shows that WP-CLI is installed. It just seems that the wp command is not recognized.
Setting Local environment variables...
----
WP-CLI: WP-CLI 2.5.0-alpha
Composer: 1.10.8 2020-06-24
PHP: 7.3.5
MySQL: mysql Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)
----
Launching shell: /bin/zsh ...
Just upgraded to 6.0.0+5444, and this behavior persists.
Quick followup. When I discovered that zsh was working properly on one of my Macs I dug in and found that my .zshrc file (customized to support Home Brew) was conflicting on my laptop. After relocating that file the site shell worked once more – though it seems like some of the wp-cli database related commands are having issues. Now I just need to get that .zshrc file playing nice with everything.
Are they the “clean” “drop” “create” “reset” subcommands?
This is a bug with the db
subcommands and needs to have some work done to refactor that wpcli code:
opened 10:56PM - 12 Feb 21 UTC
closed 01:56PM - 26 Jul 21 UTC
## Bug Report
- [x] Yes, I reviewed the [contribution guidelines](https://mak… e.wordpress.org/cli/handbook/contributing/).
- [x] Yes, more specifically, I reviewed the guidelines on [how to write clear bug reports](https://make.wordpress.org/cli/handbook/bug-reports/).
**Describe the current, buggy behavior**
When using wpcli in an environment that needs the `--defaults` flag (like [Local](https://localwp.com) ), the `clean`, `create`, `drop`, and `reset` subcommands are not working.
When running these commands, I get this error within the terminal:
```
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
```
The problem is that the above socket (`/tmp/mysql.sock`) isn't the correct one for the environment. Here are some details from my site's terminal session:
```
★ app/public % which mysql
/Applications/Local.app/Contents/Resources/extraResources/lightning-services/mysql-8.0.16+5/bin/darwin/bin/mysql
★ app/public % ps aux | grep mysql
benjamin 73741 0.2 0.6 4487024 94948 ?? S 2:01PM 0:08.94 /Applications/Local.app/Contents/Resources/extraResources/lightning-services/mysql-8.0.16+5/bin/darwin/bin/mysqld --defaults-file=/Users/benjamin/Library/Application Support/Local/run/Q1Jz6TdXS/conf/mysql/my.cnf
benjamin 75797 0.0 0.0 4258892 216 s002 U+ 2:28PM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox mysq
★ app/public % cat ~//Library/Application\ Support/Local/run/Q1Jz6TdXS/conf/mysql/my.cnf
[mysqld]
skip-name-resolve
mysqlx = 0
datadir = /Users/benjamin/Library/Application Support/Local/run/Q1Jz6TdXS/mysql/data
port = 10024
bind-address = 127.0.0.1,::1
socket = /Users/benjamin/Library/Application Support/Local/run/Q1Jz6TdXS/mysql/mysqld.sock
# Older PHP/client compatibility
character-set-server = utf8mb3
default_authentication_plugin = mysql_native_password
# Fine Tuning
performance_schema = off
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# InnoDB
innodb_buffer_pool_size = 32M
innodb_log_file_size = 96M
[client]
socket = /Users/benjamin/Library/Application Support/Local/run/Q1Jz6TdXS/mysql/mysqld.sock
user = root
password = root
```
**Describe how other contributors can replicate this bug**
You might be able to replicate by having a custom MySQL config and using the `--defaults` flag, but the easiest way I know is to use Local:
- Create a new site within [Local](https://localwp.com)
- Right-click on the site in Local and select "Open Site Shell." This will open a terminal and configure the environment variables
- Run any of the subcommands that are having issue: `clean`, `create`, `drop`, or `reset`
- You should see an error related to being unable to connect to MySQL:
```
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
```
**Describe what you would expect as the correct outcome**
I would expect that all `db` subcommands should work by being able to use the same socket connection.
**Let us know what environment you are running this on**
```
★ app/public % wp cli info
OS: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64 x86_64
Shell: /bin/zsh
PHP binary: /Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.3.5+10/bin/darwin/bin/php
PHP version: 7.3.5
php.ini used: /Users/benjamin/Library/Application Support/Local/run/Q1Jz6TdXS/conf/php/php.ini
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/benjamin/Local Sites/site-reset/app/public
WP-CLI packages dir: /Users/benjamin/.wp-cli/packages/
WP-CLI global config: /Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/config.yaml
WP-CLI project config:
WP-CLI version: 2.5.0-alpha
```
**Provide a possible solution**
Taking a look at those functions that produce errors, it seems like maybe they need to be refactored to not use `$this->run_query(...`
I'm new to the wpcli project, so I might see if I can get something working, but if anyone has pointers, I'd love to learn more!
**Provide additional context/Screenshots**
It looks like this is related to the with the work done in #157 however, a few subcommands weren't covered.
system
Closed
July 10, 2021, 4:26am
5
This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.