WP-cli does not seem to work when adding a --path
param
me@host:~$ wp plugin status --path=`/home/me/domains/example.com/public_html`
-bash: /home/me/domains/example.com/public_html: is a directory
Error: This does not seem to be a WordPress install.
Pass --path=`path/to/wordpress` or run `wp core download`.
If I cd
to the dir and then run the command without the path it does work.
I have wp-cli 0.25
Update
Extra info when adding a --debug
flag
Debug (bootstrap): No readable global config found (0.031s)
Debug (bootstrap): No project config found (0.032s)
Debug (bootstrap): No package autoload found to load. (0.39s)
Debug (bootstrap): ABSPATH defined: /home/me/domains/example.com/public_html/ (0.39s)
Anybody got a clue what I’m doing wrong?
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
.