2

Working within a Docker container (circleci/php:latest) and I'm struggling with wp-cli a bit. When I attempt to run wp core install I get a silent failure with 255 exit code. I enabled --debug hoping to get some more information but unfortunately all I can see is that it stops after reading wp-config.php.

circleci@142b5627c098:~/wordpress$ wp core install --url=example.com --title="Example" --admin_user=admin [email protected] --skip-email --debug
Debug (bootstrap): Fallback autoloader paths: phar://wp-cli.phar/vendor/autoload.php (0.01s)
Debug (bootstrap): Loading detected autoloader: phar://wp-cli.phar/vendor/autoload.php (0.011s)
Debug (commands): Adding command: cache (0.015s)
Debug (commands): Adding command: transient (0.017s)
Debug (commands): Adding command: comment (0.019s)
Debug (commands): Adding command: meta in comment Namespace (0.02s)
Debug (commands): Adding command: menu (0.021s)
Debug (commands): Adding command: item in menu Namespace (0.022s)
Debug (commands): Adding command: location in menu Namespace (0.022s)
Debug (commands): Deferring command: network meta (0.023s)
Debug (commands): Adding command: option (0.024s)
Debug (commands): Adding command: post (0.026s)
Debug (commands): Adding command: meta in post Namespace (0.026s)
Debug (commands): Adding command: term in post Namespace (0.027s)
Debug (commands): Adding command: post-type (0.028s)
Debug (commands): Adding command: site (0.03s)
Debug (commands): Adding command: meta in site Namespace (0.031s)
Debug (commands): Adding command: option in site Namespace (0.032s)
Debug (commands): Adding command: taxonomy (0.033s)
Debug (commands): Adding command: term (0.034s)
Debug (commands): Adding command: meta in term Namespace (0.035s)
Debug (commands): Adding command: user (0.037s)
Debug (commands): Adding command: meta in user Namespace (0.038s)
Debug (commands): Adding command: session in user Namespace (0.039s)
Debug (commands): Adding command: term in user Namespace (0.04s)
Debug (commands): Adding command: network (0.04s)
Debug (hooks): Processing hook "after_add_command:network" with 1 callbacks (0.04s)
Debug (hooks): On hook "after_add_command:network": Closure in file phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 634 (0.04s)
Debug (commands): Adding command: meta in network Namespace (0.041s)
Debug (commands): Adding command: db (0.044s)
Debug (commands): Adding command: plugin (0.048s)
Debug (commands): Adding command: theme (0.05s)
Debug (commands): Adding command: mod in theme Namespace (0.051s)
Debug (commands): Adding command: scaffold (0.053s)
Debug (commands): Adding command: core (0.053s)
Debug (commands): Adding command: verify-checksums in core Namespace (0.054s)
Debug (commands): Adding command: verify-checksums in plugin Namespace (0.055s)
Debug (commands): Adding command: export (0.056s)
Debug (commands): Adding command: config (0.058s)
Debug (commands): Adding command: core (0.06s)
Debug (commands): Adding command: eval (0.061s)
Debug (commands): Adding command: eval-file (0.061s)
Debug (commands): Adding command: import (0.062s)
Debug (commands): Adding command: media (0.063s)
Debug (commands): Adding command: package (0.065s)
Debug (commands): Adding command: cron (0.066s)
Debug (commands): Adding command: event in cron Namespace (0.067s)
Debug (commands): Adding command: schedule in cron Namespace (0.067s)
Debug (commands): Adding command: embed (0.068s)
Debug (commands): Adding command: fetch in embed Namespace (0.068s)
Debug (commands): Adding command: provider in embed Namespace (0.069s)
Debug (commands): Adding command: handler in embed Namespace (0.069s)
Debug (commands): Adding command: cache in embed Namespace (0.07s)
Debug (commands): Adding command: i18n (0.07s)
Debug (commands): Adding command: make-pot in i18n Namespace (0.071s)
Debug (commands): Adding command: make-json in i18n Namespace (0.072s)
Debug (commands): Deferring command: language core (0.073s)
Debug (commands): Deferring command: language plugin (0.073s)
Debug (commands): Deferring command: language theme (0.074s)
Debug (hooks): Immediately invoking on passed hook "after_add_command:site": Closure in file phar:///usr/local/bin/wp/vendor/wp-cli/language-command/language-command.php at line 39 (0.074s)
Debug (commands): Adding command: switch-language in site Namespace (0.074s)
Debug (commands): Adding command: language (0.074s)
Debug (hooks): Processing hook "after_add_command:language" with 3 callbacks (0.074s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 634 (0.074s)
Debug (commands): Adding command: core in language Namespace (0.075s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 634 (0.075s)
Debug (commands): Adding command: plugin in language Namespace (0.076s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 634 (0.076s)
Debug (commands): Adding command: theme in language Namespace (0.076s)
Debug (commands): Adding command: maintenance-mode (0.077s)
Debug (commands): Adding command: rewrite (0.078s)
Debug (commands): Adding command: rewrite (0.078s)
Debug (commands): Adding command: cap (0.079s)
Debug (commands): Adding command: role (0.08s)
Debug (commands): Adding command: search-replace (0.082s)
Debug (commands): Adding command: server (0.082s)
Debug (commands): Adding command: shell (0.083s)
Debug (commands): Adding command: super-admin (0.083s)
Debug (commands): Adding command: widget (0.085s)
Debug (commands): Adding command: sidebar (0.085s)
Debug (bootstrap): Adding framework command: phar://wp-cli.phar/vendor/wp-cli/wp-cli/php/commands/cli.php (0.085s)
Debug (commands): Adding command: cli (0.087s)
Debug (commands): Adding command: cache in cli Namespace (0.088s)
Debug (commands): Adding command: alias in cli Namespace (0.088s)
Debug (bootstrap): Adding framework command: phar://wp-cli.phar/vendor/wp-cli/wp-cli/php/commands/help.php (0.088s)
Debug (commands): Adding command: help (0.089s)
Debug (bootstrap): No readable global config found (0.089s)
Debug (bootstrap): No project config found (0.089s)
Debug (bootstrap): argv: /usr/local/bin/wp core install --url=example.com --title="Example" --admin_user=admin [email protected] --skip-email --debug (0.09s)
Debug (bootstrap): ABSPATH defined: /home/circleci/wordpress/ (0.09s)
Debug (bootstrap): Set URL: example.com (0.09s)
Debug (bootstrap): Begin WordPress load (0.09s)
Debug (bootstrap): wp-config.php path: /home/circleci/wordpress/wp-config.php (0.09s)
circleci@142b5627c098:~/wordpress$

I've tried regenerating wp-config using wp config create with just the bare minimum and visually inspected and it seems fine but no change.

3
  • Can you please elaborate a bit in which environment you are doing this (Docker), and if you can install the site from the browser? Can you please also paste your wp config create command? What does wp config list return you? Can you access mysql -uUSER -pPASSWORD from the command line?
    – leymannx
    Commented May 20, 2019 at 5:42
  • In my config.yml I have: wp config create --dbhost=127.0.0.1 --dbname=wordpress --dbuser=root --path=wordpress/ And it retuns Success: Generated 'wp-config.php' file. when I check the log. But I am also testing on a VM of my own with the same container but my setup is unfortunately slightly different so my command is: wp config create --dbhost=127.0.0.1 --dbname=wordpress --dbuser=root --path=wordpress/ Local I tried with no password as well but I though it may have been causing a problem. I have no issues using the mysql client to connect.
    – Derek Held
    Commented May 20, 2019 at 13:24
  • And when you use the same container combination as in the sample repo from my answer? Then it should work. What does your .circleci/config.yml look like?
    – leymannx
    Commented May 20, 2019 at 13:34

2 Answers 2

2

I was missing some php extensions that wp-cli and/or WordPress needed but there is no error output stating as much. I'm guessing it was specifically the missing mysqli extension.

I used a WP-CLI command to test the base container for missing extensions and now I have sudo docker-php-ext-install gd sockets mysqli exif in my config.yml.

Thanks to @leymannx for linking his own repo that got me onto the right track.

0

Ah! Now I just saw, that you are in a CircleCI container! I heavily rely on CircleCI containers for WordPress development. And I remember I once had the same problem. It's because your host needs to be specified as 127.0.0.1 with --dbhost like this:

$ wp config create --dbname=circle_test --dbuser=root --dbpass="" --dbhost=127.0.0.1

I also have a working sample repo live which may help you further: https://github.com/leymannx/wordpress-circleci-behat. Maybe you can check your .circleci/config.yml against the one from this repo to find the culprit.

1
  • 1
    So it wasn't a problem with the database host config but your repo did help me out. I was missing some php extensions that wp-cli and/or WordPress needed but there is no error output stating as much. I'm guessing it was specifically the missing mysqli extension. I used a WP-CLI command to test the base container for missing extensions and now I have sudo docker-php-ext-install gd sockets mysqli exif in my config.yml.
    – Derek Held
    Commented May 20, 2019 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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