wp-cli
wp-cli copied to clipboard
Command "scaffold theme-tests" doesn't work on v1.5.0
The command scaffold theme-tests doesn't work on v1.5.0. The error message is Error: Couldn't find install-wp-tests.sh. The same command works fine with v1.4.1.
What about other subcommands? Maybe coincidence but I had trouble with package-readme a few minutes ago: Error: 'package-readme' is not a registered subcommand of 'scaffold'. See 'wp help scaffold' for available subcommands.
scaffold plugin-tests crashes with the same error as scaffold theme-tests.
I can't reproduce this. Could you post the output of wp cli info please @SergeC , and also try running the command(s) with the --debug flag?
(Just to note the error message at Scaffold_Command.php#L1097 should use $template_path not $template)
➜ catalog git:(master) ✗./wp-cli cli info OS: Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64 Shell: /bin/zsh PHP binary: /usr/local/Cellar/php72/7.2.2_13/bin/php PHP version: 7.2.2 php.ini used: /usr/local/etc/php/7.2/php.ini WP-CLI root dir: phar://wp-cli.phar WP-CLI vendor dir: phar://wp-cli.phar/vendor WP_CLI phar path: /Users/sergey/Desktop/catalog WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config: /Users/sergey/Desktop/catalog/wp-cli.yml WP-CLI version: 1.5.0 ➜ catalog git:(master) ✗ php wp-cli-1.4.1.phar cli info
PHP binary: /usr/local/Cellar/php72/7.2.2_13/bin/php PHP version: 7.2.2 php.ini used: /usr/local/etc/php/7.2/php.ini WP-CLI root dir: phar://wp-cli.phar WP-CLI vendor dir: phar://wp-cli.phar/vendor WP_CLI phar path: /Users/sergey/Desktop/catalog WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config: /Users/sergey/Desktop/catalog/wp-cli.yml WP-CLI version: 1.4.1 ➜ catalog git:(master) ✗ ./wp-cli scaffold theme-tests coinnews --debug Debug (bootstrap): No readable global config found (0.107s) Debug (bootstrap): Using project config: /Users/sergey/Desktop/catalog/wp-cli.yml (0.108s) Debug (bootstrap): argv: ./wp-cli scaffold theme-tests coinnews --debug (0.108s) Debug (bootstrap): ABSPATH defined: /Users/sergey/Desktop/catalog/wp/ (0.108s) Debug (bootstrap): Begin WordPress load (0.109s) Debug (bootstrap): wp-config.php path: /Users/sergey/Desktop/catalog/wp/wp-config.php (0.109s) Debug (bootstrap): Set URL: catalog.com/ (0.112s) Debug (bootstrap): Loaded WordPress (0.359s) Debug (bootstrap): Running command: scaffold theme-tests (0.359s) Error: Couldn't find install-wp-tests.sh ➜ catalog git:(master) ✗ php wp-cli-1.4.1.phar scaffold theme-tests coinnews --debug Debug (bootstrap): No readable global config found (0.098s) Debug (bootstrap): Using project config: /Users/sergey/Desktop/catalog/wp-cli.yml (0.1s) Debug (bootstrap): argv: wp-cli-1.4.1.phar scaffold theme-tests coinnews --debug (0.1s) Debug (bootstrap): ABSPATH defined: /Users/sergey/Desktop/catalog/wp/ (0.102s) Debug (bootstrap): Begin WordPress load (0.102s) Debug (bootstrap): wp-config.php path: /Users/sergey/Desktop/catalog/wp/wp-config.php (0.102s) Debug (bootstrap): Set URL: catalog.com/ (0.106s) Debug (bootstrap): Loaded WordPress (0.35s) Debug (bootstrap): Running command: scaffold theme-tests (0.352s) Success: Created test files.
➜ catalog git:(master) ✗cat wp-cli.yml path: wp
Okay this is a weird bug which depends on how your WP-CLI phar is named and where it resides, and follows from https://github.com/wp-cli/wp-cli/pull/4024 so is present from v1.2.0 on. It doesn't arise if your WP-CLI phar has a .phar extension or if it's not in your pwd (PHP getcwd()) path.
So as a temporary workaround if you rename your v1.5.0 /Users/sergey/Desktop/catalog/wp-cli phar to /Users/sergey/Desktop/catalog/wp-cli.phar then the issue should go away, or if you move it to say /usr/local/bin or anywhere not under your current working directory, in which case you don't need the .phar extension.
I've added .phar extension and 1.5.0 successfully generated tests.
➜ catalog git:(master) ✗ ./wp-cli.phar scaffold theme-tests coinnews --debug Debug (bootstrap): No readable global config found (0.108s) Debug (bootstrap): Using project config: /Users/sergey/Desktop/catalog/wp-cli.yml (0.109s) Debug (bootstrap): argv: ./wp-cli.phar scaffold theme-tests coinnews --debug (0.109s) Debug (bootstrap): ABSPATH defined: /Users/sergey/Desktop/catalog/wp/ (0.109s) Debug (bootstrap): Begin WordPress load (0.11s) Debug (bootstrap): wp-config.php path: /Users/sergey/Desktop/catalog/wp/wp-config.php (0.11s) Debug (bootstrap): Set URL: catalog.com/ (0.115s) Debug (bootstrap): Loaded WordPress (0.359s) Debug (bootstrap): Running command: scaffold theme-tests (0.36s) Success: Created test files. ➜ catalog git:(master) ✗ ./wp-cli.phar cli info
OS: Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64 Shell: /bin/zsh PHP binary: /usr/local/Cellar/php72/7.2.2_13/bin/php PHP version: 7.2.2 php.ini used: /usr/local/etc/php/7.2/php.ini WP-CLI root dir: phar://wp-cli.phar WP-CLI vendor dir: phar://wp-cli.phar/vendor WP_CLI phar path: /Users/sergey/Desktop/catalog WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config: /Users/sergey/Desktop/catalog/wp-cli.yml WP-CLI version: 1.5.0
I also see weird subcommand breakage w/ 1.5.0. Reverting to 1.4.1 works. I can't tell from the surface whether it's related to this specific issue #4689 or not.
Breaking example:
[convers@pill2 ~/www/wp-content/plugins]# wp wc memberships plan
usage: wp wc memberships plan create [--<field>=<value>]
or: wp wc memberships plan delete <id>...
or: wp wc memberships plan get <id> [--field=<field>] [--fields=<fields>] [--format=<format>]
or: wp wc memberships plan list [--field=<field>] [--fields=<fields>] [--format=<format>]
or: wp wc memberships plan rule <command>
or: wp wc memberships plan update <id> [--<field>=<value>]
See 'wp help wc memberships plan <command>' for more information on a specific command.
[convers@pill2 ~/www/wp-content/plugins]# wp wc memberships plan list
Error: 'plan' is not a registered subcommand of 'wc memberships'. See 'wp help wc memberships' for available subcommands.
@lkraav this doesn't look like the same issue to me. Could you create a new issue for this? (Though I note that woocommerce memberships is a paid-for plugin so it will be difficult to reproduce/test. Also standard woocommerce commands seem to work ok (on limited testing).)
creating the wp-config file doesnt seem to work:
./wp --info
OS: Linux 5.4.0-58-generic #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.4
PHP version: 7.4.3
php.ini used: /etc/php/7.4/cli/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /media/daniel/lindata/proyectos/_moje/php/testwp
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0
./wp config create --dbname=wptest --dbuser=root --dbhost=127.0.0.1
PHP Warning: file_get_contents(phar://wp-cli.phar/vendor/wp-cli/wp-cli/templates/phar://wp/vendor/wp-cli/config-command/templates/wp-config.mustache): failed to open stream: phar error: "vendor/wp-cli/wp-cli/templates/phar:/wp/vendor/wp-cli/config-command/templates/wp-config.mustache" is not a file in phar "wp-cli.phar" in phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/utils.php on line 506
PHP Stack trace:
PHP 1. {main}() /media/daniel/lindata/proyectos/_moje/php/testwp/wp:0
PHP 2. include() /media/daniel/lindata/proyectos/_moje/php/testwp/wp:4
PHP 3. include() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/php/boot-phar.php:11
PHP 4. WP_CLI\bootstrap() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/wp-cli.php:27
PHP 5. WP_CLI\Bootstrap\LaunchRunner->process() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/bootstrap.php:74
PHP 6. WP_CLI\Runner->start() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php:23
PHP 7. WP_CLI\Runner->run_command_and_exit() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:1107
PHP 8. WP_CLI\Runner->run_command() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:394
PHP 9. WP_CLI\Dispatcher\Subcommand->invoke() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:371
PHP 10. call_user_func:{phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php:451}() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php:451
PHP 11. WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure:phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php:95-102}() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php:451
PHP 12. call_user_func:{phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php:98}() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php:98
PHP 13. Config_Command->create() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php:98
PHP 14. WP_CLI\Utils\mustache_render() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/config-command/src/Config_Command.php:162
PHP 15. file_get_contents() phar:///media/daniel/lindata/proyectos/_moje/php/testwp/wp/vendor/wp-cli/wp-cli/php/utils.php:506
Error: Could not create new 'wp-config.php' file.
changing the name works fine:
./wp-cli.phar config create --dbname=wptest --dbuser=root --dbhost=127.0.0.1
Success: Generated 'wp-config.php' file.
Just leaving a note that I am also running into this issue when installing via composer to a symfony project and trying to execute commands on it.
Just wanted to add that I experienced this bug today. I initially renamed wp-cli.phar to wpcli for convenience sake. Up till now the commands I used (plugin/list|activate|deactivate, core/download) all work fine but config/create fails with "Error: Could not create new 'wp-config.php' file." but runs fine when the script has its original name wp-cli.phar
Using WP-CLI 2.10.0
FYI this was in the error log:
[05-Mar-2024 20:15:52 America/New_York] PHP Warning: file_get_contents(phar://wp-cli.phar/vendor/wp-cli/wp-cli/templates/phar://bin/wpcli/vendor/wp-cli/config-command/templates/wp-config.mustache): Failed to open stream: phar error: "vendor/wp-cli/wp-cli/templates/phar:/bin/wpcli/vendor/wp-cli/config-command/templates/wp-config.mustache" is not a file in phar "wp-cli.phar" in phar:///home/user7/bin/wpcli/vendor/wp-cli/wp-cli/php/utils.php on line 608
Seems like the paths used for accessing the Mustache template files within the Phar file will need to be wrapped in Utils\phar_safe_path(). This should ensure they will always correctly resolve.