Roots Discourse

Wp-cli aliases on latest bedrock


#1

Hello, kind of a weird question. Hoping it’s just me as I haven’t seen any mention of this in discourse.

On the latest bedrock cloned today, I have to set my wp-cli alias server path to be: “/srv/www/website.com/current/web/wp” in order for it to detect the wordpress install.

In past versions of bedrock I could set it to something like this for easily interacting with sql files in a special folder: “/srv/www/website.com/current/db”
However, that does not work anymore. Nor does: “/srv/www/website.com/current” - where both worked fine previously.

I wonder if this has to do with the new roots/wp-config and/or how WP_CONTENT_DIR is defined?

The path examples In the roots guide https://roots.io/guides/using-wp-cli-aliases/ are like what used to work for me.


#2

Can you please share your full WP-CLI config that shows the aliases and the messages that you’re seeing when attempting to use them?


#3

wp-cli.yml in site directory:

path: web/wp

@prod:
  ssh: admin@xxx.xxx.xxx/srv/www/website.com/current

@staging:
  ssh: admin@xxx.xxx.xxx/srv/www/website.com/current

@dev:
  ssh: vagrant@website.test/srv/www/website.com/current

Sample command with debug:

wp @dev db reset --debug
Debug (bootstrap): Loading packages from: /Users/*user*/.wp-cli/packages/vendor/autoload.php (0.028s)
Debug (bootstrap): No readable global config found (0.103s)
Debug (bootstrap): Using project config: /*site-directory*/wp-cli.yml (0.103s)
Debug (bootstrap): argv: /usr/local/bin/wp @dev db reset --debug (0.103s)
Debug (bootstrap): SSH scheme:  (0.104s)
Debug (bootstrap): SSH user: vagrant (0.104s)
Debug (bootstrap): SSH host: website.test (0.104s)
Debug (bootstrap): SSH port:  (0.104s)
Debug (bootstrap): SSH path: /srv/www/website.com/current (0.104s)
Debug (bootstrap): Running SSH command: ssh -q 'vagrant@website.test' -t 'cd '\''/srv/www/website.com/current'\''; wp '\''db'\'' '\''reset'\'' '\''--debug'\''' (0.105s)
Debug (bootstrap): Framework autoloader paths: phar://wp-cli.phar/vendor/autoload.php (0.074s)
Debug (bootstrap): Loading detected autoloader: phar://wp-cli.phar/vendor/autoload.php (0.076s)
Debug (commands): Adding command: cache (0.077s)
Debug (commands): Adding command: transient (0.077s)
Debug (commands): Adding command: comment (0.078s)
Debug (commands): Adding command: comment meta (0.079s)
Debug (commands): Adding command: menu (0.079s)
Debug (commands): Adding command: menu item (0.079s)
Debug (commands): Adding command: menu location (0.079s)
Debug (commands): Deferring command: network meta (0.079s)
Debug (commands): Adding command: option (0.079s)
Debug (commands): Adding command: post (0.079s)
Debug (commands): Adding command: post meta (0.079s)
Debug (commands): Adding command: post term (0.079s)
Debug (commands): Adding command: post-type (0.079s)
Debug (commands): Adding command: site (0.079s)
Debug (commands): Adding command: site meta (0.079s)
Debug (commands): Adding command: site option (0.079s)
Debug (commands): Adding command: taxonomy (0.079s)
Debug (commands): Adding command: term (0.079s)
Debug (commands): Adding command: term meta (0.079s)
Debug (commands): Adding command: user (0.079s)
Debug (commands): Adding command: user meta (0.079s)
Debug (commands): Adding command: user session (0.079s)
Debug (commands): Adding command: user term (0.079s)
Debug (commands): Adding command: network (0.079s)
Debug (hooks): Processing hook "after_add_command:network" with 1 callbacks (0.079s)
Debug (hooks): On hook "after_add_command:network": Closure in file phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 602 (0.08s)
Debug (commands): Adding command: network meta (0.08s)
Debug (commands): Adding command: db (0.08s)
Debug (commands): Adding command: plugin (0.08s)
Debug (commands): Adding command: theme (0.08s)
Debug (commands): Adding command: theme mod (0.08s)
Debug (commands): Adding command: scaffold (0.08s)
Debug (hooks): Immediately invoking on passed hook "after_add_command:plugin": Closure in file phar:///usr/bin/wp/vendor/wp-cli/checksum-command/checksum-command.php at line 16 (0.08s)
Debug (commands): Adding command: plugin verify-checksums (0.08s)
Debug (commands): Adding command: export (0.08s)
Debug (commands): Adding command: config (0.08s)
Debug (commands): Adding command: core (0.08s)
Debug (hooks): Processing hook "after_add_command:core" with 1 callbacks (0.08s)
Debug (hooks): On hook "after_add_command:core": Closure in file phar:///usr/bin/wp/vendor/wp-cli/checksum-command/checksum-command.php at line 12 (0.08s)
Debug (commands): Adding command: core verify-checksums (0.08s)
Debug (commands): Adding command: eval (0.08s)
Debug (commands): Adding command: eval-file (0.08s)
Debug (commands): Adding command: import (0.08s)
Debug (commands): Adding command: media (0.08s)
Debug (commands): Adding command: package (0.08s)
Debug (commands): Adding command: cron (0.08s)
Debug (commands): Adding command: cron event (0.08s)
Debug (commands): Adding command: cron schedule (0.08s)
Debug (commands): Adding command: embed (0.08s)
Debug (commands): Adding command: embed fetch (0.08s)
Debug (commands): Adding command: embed provider (0.08s)
Debug (commands): Adding command: embed handler (0.08s)
Debug (commands): Adding command: embed cache (0.081s)
Debug (commands): Adding command: i18n (0.081s)
Debug (commands): Adding command: i18n make-pot (0.081s)
Debug (commands): Deferring command: language core (0.081s)
Debug (commands): Deferring command: language plugin (0.081s)
Debug (commands): Deferring command: language theme (0.081s)
Debug (hooks): Immediately invoking on passed hook "after_add_command:site": Closure in file phar:///usr/bin/wp/vendor/wp-cli/language-command/language-command.php at line 37 (0.081s)
Debug (commands): Adding command: site switch-language (0.081s)
Debug (commands): Adding command: language (0.081s)
Debug (hooks): Processing hook "after_add_command:language" with 3 callbacks (0.081s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 602 (0.081s)
Debug (commands): Adding command: language core (0.081s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 602 (0.081s)
Debug (commands): Adding command: language plugin (0.081s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 602 (0.081s)
Debug (commands): Adding command: language theme (0.081s)
Debug (commands): Adding command: rewrite (0.081s)
Debug (commands): Adding command: rewrite (0.081s)
Debug (commands): Adding command: cap (0.081s)
Debug (commands): Adding command: role (0.081s)
Debug (commands): Adding command: search-replace (0.081s)
Debug (commands): Adding command: server (0.081s)
Debug (commands): Adding command: shell (0.081s)
Debug (commands): Adding command: super-admin (0.081s)
Debug (commands): Adding command: widget (0.081s)
Debug (commands): Adding command: sidebar (0.081s)
Debug (bootstrap): Loading packages from: /home/vagrant/.wp-cli/packages/vendor/autoload.php (0.081s)
Debug (bootstrap): Loading detected autoloader: /home/vagrant/.wp-cli/packages/vendor/autoload.php (0.081s)
Debug (commands): Adding command: login (0.084s)
Debug (bootstrap): Adding framework command: phar://wp-cli.phar/vendor/wp-cli/wp-cli/php/commands/cli.php (0.086s)
Debug (commands): Adding command: cli (0.089s)
Debug (bootstrap): Adding framework command: phar://wp-cli.phar/vendor/wp-cli/wp-cli/php/commands/help.php (0.09s)
Debug (commands): Adding command: help (0.092s)
Debug (bootstrap): Fallback autoloader paths: phar://wp-cli.phar/vendor/autoload.php (0.093s)
Debug (bootstrap): Loading detected autoloader: phar://wp-cli.phar/vendor/autoload.php (0.094s)
Debug (bootstrap): No readable global config found (0.095s)
Debug (bootstrap): No project config found (0.096s)
Debug (bootstrap): argv: /usr/bin/wp db reset --debug (0.096s)
Debug (bootstrap): ABSPATH defined: / (0.097s)
Error: This does not seem to be a WordPress install.
Pass --path=`path/to/wordpress` or run `wp core download`.

Wordpress is indeed installed and the site pulls up in a browser


#4

Working fine for me with latest Trellis and Bedrock:

# site/wp-cli.yml
path: web/wp

@dev:
  ssh: vagrant@example.test/srv/www/example.com/current
~/S/e/site ❯❯❯ wp @dev db reset --debug

Debug (bootstrap): Loading packages from: /Users/benword/.wp-cli/packages/vendor/autoload.php (0.01s)
Debug (commandfactory): No doc comment for blade. (0.014s)
Debug (bootstrap): No readable global config found (0.06s)
Debug (bootstrap): Using project config: /Users/benword/Sites/example.com/site/wp-cli.yml (0.06s)
Debug (bootstrap): argv: /usr/local/bin/wp @dev db reset --debug (0.06s)
Debug (bootstrap): SSH scheme:  (0.06s)
Debug (bootstrap): SSH user: vagrant (0.06s)
Debug (bootstrap): SSH host: example.test (0.06s)
Debug (bootstrap): SSH port:  (0.06s)
Debug (bootstrap): SSH path: /srv/www/example.com/current (0.06s)
Debug (bootstrap): Running SSH command: ssh -q 'vagrant@example.test' -t 'cd '\''/srv/www/example.com/current'\''; wp '\''db'\'' '\''reset'\'' '\''--debug'\''' (0.06s)
Debug (bootstrap): Framework autoloader paths: phar://wp-cli.phar/vendor/autoload.php (0.038s)
Debug (bootstrap): Loading detected autoloader: phar://wp-cli.phar/vendor/autoload.php (0.039s)
Debug (commands): Adding command: cache (0.039s)
Debug (commands): Adding command: transient (0.04s)
Debug (commands): Adding command: comment (0.04s)
Debug (commands): Adding command: comment meta (0.04s)
Debug (commands): Adding command: menu (0.041s)
Debug (commands): Adding command: menu item (0.041s)
Debug (commands): Adding command: menu location (0.041s)
Debug (commands): Deferring command: network meta (0.042s)
Debug (commands): Adding command: option (0.042s)
Debug (commands): Adding command: post (0.042s)
Debug (commands): Adding command: post meta (0.042s)
Debug (commands): Adding command: post term (0.043s)
Debug (commands): Adding command: post-type (0.043s)
Debug (commands): Adding command: site (0.043s)
Debug (commands): Adding command: site meta (0.043s)
Debug (commands): Adding command: site option (0.043s)
Debug (commands): Adding command: taxonomy (0.043s)
Debug (commands): Adding command: term (0.043s)
Debug (commands): Adding command: term meta (0.043s)
Debug (commands): Adding command: user (0.043s)
Debug (commands): Adding command: user meta (0.043s)
Debug (commands): Adding command: user session (0.043s)
Debug (commands): Adding command: user term (0.043s)
Debug (commands): Adding command: network (0.043s)
Debug (hooks): Processing hook "after_add_command:network" with 1 callbacks (0.043s)
Debug (hooks): On hook "after_add_command:network": Closure in file phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 602 (0.043s)
Debug (commands): Adding command: network meta (0.043s)
Debug (commands): Adding command: db (0.043s)
Debug (commands): Adding command: plugin (0.043s)
Debug (commands): Adding command: theme (0.043s)
Debug (commands): Adding command: theme mod (0.043s)
Debug (commands): Adding command: scaffold (0.043s)
Debug (hooks): Immediately invoking on passed hook "after_add_command:plugin": Closure in file phar:///usr/bin/wp/vendor/wp-cli/checksum-command/checksum-command.php at line 16 (0.043s)
Debug (commands): Adding command: plugin verify-checksums (0.043s)
Debug (commands): Adding command: export (0.043s)
Debug (commands): Adding command: config (0.043s)
Debug (commands): Adding command: core (0.044s)
Debug (hooks): Processing hook "after_add_command:core" with 1 callbacks (0.044s)
Debug (hooks): On hook "after_add_command:core": Closure in file phar:///usr/bin/wp/vendor/wp-cli/checksum-command/checksum-command.php at line 12 (0.044s)
Debug (commands): Adding command: core verify-checksums (0.044s)
Debug (commands): Adding command: eval (0.044s)
Debug (commands): Adding command: eval-file (0.044s)
Debug (commands): Adding command: import (0.044s)
Debug (commands): Adding command: media (0.044s)
Debug (commands): Adding command: package (0.044s)
Debug (commands): Adding command: cron (0.044s)
Debug (commands): Adding command: cron event (0.044s)
Debug (commands): Adding command: cron schedule (0.044s)
Debug (commands): Adding command: embed (0.044s)
Debug (commands): Adding command: embed fetch (0.044s)
Debug (commands): Adding command: embed provider (0.044s)
Debug (commands): Adding command: embed handler (0.044s)
Debug (commands): Adding command: embed cache (0.044s)
Debug (commands): Adding command: i18n (0.044s)
Debug (commands): Adding command: i18n make-pot (0.044s)
Debug (commands): Deferring command: language core (0.044s)
Debug (commands): Deferring command: language plugin (0.044s)
Debug (commands): Deferring command: language theme (0.044s)
Debug (hooks): Immediately invoking on passed hook "after_add_command:site": Closure in file phar:///usr/bin/wp/vendor/wp-cli/language-command/language-command.php at line 37 (0.044s)
Debug (commands): Adding command: site switch-language (0.044s)
Debug (commands): Adding command: language (0.044s)
Debug (hooks): Processing hook "after_add_command:language" with 3 callbacks (0.044s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 602 (0.044s)
Debug (commands): Adding command: language core (0.044s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 602 (0.044s)
Debug (commands): Adding command: language plugin (0.044s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 602 (0.045s)
Debug (commands): Adding command: language theme (0.045s)
Debug (commands): Adding command: rewrite (0.045s)
Debug (commands): Adding command: rewrite (0.045s)
Debug (commands): Adding command: cap (0.045s)
Debug (commands): Adding command: role (0.045s)
Debug (commands): Adding command: search-replace (0.045s)
Debug (commands): Adding command: server (0.045s)
Debug (commands): Adding command: shell (0.045s)
Debug (commands): Adding command: super-admin (0.045s)
Debug (commands): Adding command: widget (0.045s)
Debug (commands): Adding command: sidebar (0.045s)
Debug (bootstrap): Adding framework command: phar://wp-cli.phar/vendor/wp-cli/wp-cli/php/commands/cli.php (0.045s)
Debug (commands): Adding command: cli (0.046s)
Debug (bootstrap): Adding framework command: phar://wp-cli.phar/vendor/wp-cli/wp-cli/php/commands/help.php (0.046s)
Debug (commands): Adding command: help (0.047s)
Debug (bootstrap): Fallback autoloader paths: phar://wp-cli.phar/vendor/autoload.php (0.048s)
Debug (bootstrap): Loading detected autoloader: phar://wp-cli.phar/vendor/autoload.php (0.049s)
Debug (bootstrap): No readable global config found (0.049s)
Debug (bootstrap): Using project config: /srv/www/example.com/current/wp-cli.yml (0.05s)
Debug (bootstrap): argv: /usr/bin/wp db reset --debug (0.05s)
Debug (bootstrap): ABSPATH defined: /srv/www/example.com/current/web/wp/ (0.051s)
Debug (bootstrap): Begin WordPress load (0.052s)
Debug (bootstrap): wp-config.php path: /srv/www/example.com/current/web/wp-config.php (0.052s)
Debug (hooks): Processing hook "before_run_command" with 1 callbacks (0.06s)
Debug (hooks): On hook "before_run_command": WP_CLI\Bootstrap\RegisterDeferredCommands->add_deferred_commands() (0.06s)
Debug (bootstrap): Running command: db reset (0.061s)
Are you sure you want to reset the 'example_com_development' database? [y/n]

#5

Thank you for testing that, it helped me solve this in short order.

•	Updated global wp-cli from 1.5 to latest
•	composer clear-cache
•	ran composer update on the site with latest bedrock successfully
•	ran vagrant provision and encountered a new error installing acf pro  on a site that had an old version of bedrock (there’s multiple sites on this trellis).
•	Then removed all but the one site with latest bedrock from wordpress_sites and vault, and ran vagrant provision again - got a new error about a plugin in the lock file of the remaining site - but the lock file it’s referencing was the one from the old bedrock version of the site. (no longer had the plugin it was complaining about)
•	ran composer update on the site with latest bedrock successfully - new stuff was downloaded.
•	vagrant destroyed
•	vagrant up
•	wp-cli aliases work now

I must have ran vagrant up before updating bedrock. I made a script that renames the old bedrock site folder, creates a new bedrock site with composer create-project using the original directory name, and then copies in my theme and uploads. Maybe trellis was still aliased to the old directory - best i can guess.

Thanks


closed #6

This topic was automatically closed after 42 days. New replies are no longer allowed.