4

I am trying to set up a wp-cli.yml file but every time I run the command, the file is ignored.

Where should the file be located? And how should I call the command to use it?

I tried having a file in the project's root directory, as well as a folder above. I have also tried using the following file names:

wp-cli.local.yml, wp-cli.yml

The I tried running something like:

wp local core download

But I keep getting the following error:

Error: This does not seem to be a WordPress install. Pass --path=path/to/wordpress or run wp core download.

PS: I am not sure wp-cli questions are off topic because I see tons of questions about wp-cli with answers, and I also see that there's a wp-cli tag. If this questions is off topic, please let me know before down voting it, and I will remove it.

6

TL;DR:

  1. Run wp version --debug
  2. Check that wp-cli.yml was found
  3. Check that the ABSPATH set by WP-CLI matches the directory where WP is installed
  4. Look at find_wp_root() for hints about why it's finding the wrong folder

The docs say:

inside the current working directory (or upwards)

...so you should be able to use it in parent directories, not just in the directory where you call wp from. i.e., you should be able to have it several levels above the folder where Core is installed, and then call it from anywhere below the directory where wp-cli.yml is installed [1].

Was wp-cli.yml included?

You can find out by running wp version --debug

  • Found: Debug: Using project config: /var/www/example.localhost/wp-cli.yml (0.012s)
  • NOT Found: Debug: No project config found (0.014s)

Is WP-CLI's ABSPATH set correctly?

Note: This is the ABSPATH that WP-CLI defines internally, not the one from your wp-config.php

WP-CLI's internal ABSPATH is what it uses to find WordPress [2, 3], so if it's wrong then you'll get the This does not seem to be a WordPress install error.

To find out if it's wrong, you can run wp version --debug from a few different directories, and look at the ABSPATH output. Does it match the actual path to the folder where Core is installed?

Assuming the path to WP is /var/www/example.localhost/web/wordpress/, then:

  • Correct: Debug: ABSPATH defined: ABSPATH defined: /var/www/example.localhost/web/wordpress/ (0.013s)
  • Incorrect: Debug: ABSPATH defined: /var/www/example.localhost/web/content/plugins/akismet/wordpress/ (0.019s)

Keep in mind that any arguments passed via parameters (e.g., wp --path=foo) will override the values in wp-cli.yml.

Why is ABSPATH wrong?

There are probably lots of different causes for it being wrong, because it depends on how your folder structure is setup, the path defined in wp-cli.yml, etc.

ABSPATH is set to the value of find_wp_root()[4, 5, 6], so that's where you need to start troubleshooting.

You can read through find_wp_root() and mentally step through the code, looking for clues. If you have WP-CLI installed via composer, then you can also edit Runner.php to add debugging output to find_wp_root(), use Xdebug, etc.

In my case, I had a Bash alias setup for wp that was passing --path to the command, which was overriding the path set in wp-cli.yml, but I'd forgotten about it.

2

According to the docs wp-cli.yml should be in the working directory where you are calling wp commands. Inside the file you should have the path to the WordPress install relative to the file's location.

Using VVV as an example, the file structure would have a site-name folder where I would call the 'WP_CLI' commands. Inside that directory is an htdocs folder where the WordPress files are located and the wp-cli.yml file that contains this:

path: htdocs

Hope this helps!

0

with me it works with me this way

path: E:\xampp\htdocs\wordpress

it should be added to wp-cli.yml which located at the same directory where the wp cli is installed
i use it in windows so i used full path not relative

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.