brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: the debug flag shows why a WP-CLI command on WordPress fails

WordPress
~/tips/tip-wordpress-cli-debug-flag

wp plugin list --debug

Prints every PHP error and the steps WP-CLI takes while loading the site.

Sometimes a WP-CLI command just stops with “Error establishing a database connection” or prints nothing. The global --debug flag shows what happened on the way.

Add it to any command:

wp plugin list --debug

Two things change. All PHP errors, warnings and notices are shown, also the ones WP_DEBUG would hide. And WP-CLI explains its own startup: which config files it read, which WordPress path it found, how long each step took. The extra lines start with Debug and go to standard error, so the normal output stays clean if you pipe it somewhere.

When the output is long, filter it:

wp plugin list --debug 2>&1 | grep -i -E 'warning|error|fatal'

I’d reach for it in three cases: WP-CLI picks up the wrong wp-cli.yml, a plugin throws a fatal error only on the command line, or a command is mysteriously slow and you want the timings.

There is a debug key for wp-cli.yml as well, but I would not leave that on. The noise drowns out real output, and notices from plugins can include file paths and values you don’t want in a log that others read.

Further reading: WP-CLI global parameters

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link