wp-cli / config-command

Generates and reads the wp-config.php file.
MIT License
38 stars 36 forks source link

wp-config.mustache is not a file in phar #141

Open eduararley opened 2 years ago

eduararley commented 2 years ago

Bug Report

Describe the current, buggy behavior

When wp-cli.phar is renamed to wp and moved into a path location, --path option seems to have conflict with wp create command. This has been reported before (#31)

Describe how other contributors can replicate this bug

$ curl -Lso ~/.local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
$ chmod +x ~/.local/bin/wp
$ wp core download --path=subfolder
Downloading WordPress 5.9 (en_US)...
md5 hash verified: b2ed7e1e6cf834564273f5b4581afd29
Success: WordPress downloaded.
$ wp config create --path=subfolder --dbname=mydb --dbuser=myuser --dbpass=mypass --skip-check --force
PHP Warning:  file_get_contents(phar://wp-cli.phar/vendor/wp-cli/wp-cli/templates/phar://.local/bin/wp/vendor/wp-cli/config-command/templates/wp-config.mustache): failed to open stream: phar error: "vendor/wp-cli/wp-cli/templates/phar:/.local/bin/wp/vendor/wp-cli/config-command/templates/wp-config.mustache" is not a file in phar "wp-cli.phar" in phar:///home/interface/.local/bin/wp/vendor/wp-cli/wp-cli/php/utils.php on line 577
Error: Could not create new 'wp-config.php' file.

However, with just a cd to the subfolder, it works just fine:

$ cd subfolder
$ wp config create --dbname=mydb --dbuser=myuser --dbpass=mypass --skip-check --force
Success: Generated 'wp-config.php' file.

Also, if I rename wp to wp-cli.phar, it works:

$ mv ~/.local/bin/wp ~/.local/bin/wp-cli.phar
$ wp-cli.phar config create --path=subfolder --dbname=mydb --dbuser=myuser --dbpass=mypass --skip-check --force
Success: Generated 'wp-config.php' file.

Describe what you would expect as the correct outcome

Success: Generated 'wp-config.php' file.

Let us know what environment you are running this on

OS: Linux 3.10.0-1160.53.1.el7.x86_64 #1 SMP Fri Jan 14 13:59:45 UTC 2022 x86_64
Shell:  /bin/bash
PHP binary: /opt/rh/rh-php73/root/usr/bin/php
PHP version:    7.3.29
php.ini used:   /etc/opt/rh/rh-php73/php.ini
MySQL binary:   /opt/rh/rh-mariadb103/root/usr/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.3.28-MariaDB, for Linux (x86_64) using  EditLine wrapper
SQL modes:  
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:   /home/myuser
WP-CLI packages dir:    
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 2.6.0
schlessera commented 2 years ago

Looks like the path resolution to identify the vendor folder to use is unexpectedly picking up on the --path flag somehow.