WP cli –path does not seem to work

It’s as if you were trying to run:

wp plugin status --path=$(/home/me/domains/example.com/public_html)

because what’s inside the backticks get’s evaluated.

Here’s a good reading about using backticks in the command line.

Let me quote @rozcietrzewiacz:

Backtick is not a quotation sign, it has a very
special meaning. Everything you type between backticks is evaluated
(executed) by the shell before the main command […]

Alternatives:

wp plugin status --path=/home/me/domains/example.com/public_html
wp plugin status --path="/home/me/domains/example.com/public_html"
wp plugin status --path="/home/me/domains/example.com/public_html"

When I use the wp-skeleton setup, I have to point to the wp/ core folder, not the folder above it containing the wp-config.php file.

Update:

Within the Runner class we have:

/**
 * Do WordPress core files exist?
 *
 * @return bool
 */
private function wp_exists() {
    return is_readable( ABSPATH . 'wp-includes/version.php' );
}

and when we set ABSPATH with

--path=/home/me/domains/example.com/public_html/ 

it looks like we are using:

/**
 * Set WordPress root as a given path.
 *
 * @param string $path
 */
private static function set_wp_root( $path ) {
    define( 'ABSPATH', rtrim( $path, "https://wordpress.stackexchange.com/" ) . "https://wordpress.stackexchange.com/" );
    WP_CLI::debug( 'ABSPATH defined: ' . ABSPATH, 'bootstrap' );
    $_SERVER['DOCUMENT_ROOT'] = realpath( $path );
}

and then:

 is_readable( '/home/me/domains/example.com/public_html/wp-includes/version.php' )

becomes false because with the wp-skeleton setup, the core directory is:

/home/me/domains/example.com/public_html/wp/ 

This test is necessary but not sufficient. There are other tests, e.g. the Runner::find_wp_root() method.

The reason why it works when OP is located within:

/home/me/domains/example.com/public_html/

could be because of the Runner::extract_subdir_path() method that scans the content of the index.php file with:

$index_code = file_get_contents( $index_path );

if ( !preg_match( 
         '|^\s*require\s*\(?\s*(.+?)/wp-blog-header\.php([\'"])|m', 
         $index_code, 
         $matches 
     ) 
) {
        return false;
}

to get the subdirectory where the wp-blog-header.php file is located and set it as the $wp_path.

Leave a Comment