8

I just updated to wp-cli 0.14.1 today and once again having a MySQL issue. I'm on Windows, Wampserver, and Cygwin.

When I first updated to the last rev (0.14.0) I had a similar problem and wound up finding and using the info from a github discussion that it most likely was due to the "variables_order" in php.ini. I commented that out in my ini file in order to force the default of EGPCS instead of GPCS. That took care of it. There was mention of fixing this in the next release.

Now I've updated to 0.14.1 and when trying to run "wp core config ...." to create the wp-config.php file I"m getting the command line error

MYSQL_PWD is not recognized as an internal or external command.

I went back to the github thread and see that scribu did make the change discussed. I followed the link to it to see if it would shed some light. I see the change on line 328 but don't know what I should try now since that change seems to be what's producing my problem.

Just FYI: I have no problem using mysql from the DOS or Cygwin command line, they both reference the same executable and work correctly; flawlessly.

Any help would be appreciated.

UPDATED 03/08/2014

NOTES: (1) I'm not concerned with exposing the username or password as they are temporary and this is on one of my local machines. (2) You'll see I"m using the phar file in this debug session. The exact same thing happens using the "installed" version "wp" in the bin folder.

Here's a debug session in PHPStorm in which I started with this wp-cli command:

Boss@Bonkers /cygdrive/c/wamp/www/wpsandbox
$ ../wp-cli-0.14.1.phar core config --dbhost=127.0.0.1 --dbname=wpsandbox --dbuser=root --dbpass=Bonkers --dbprefix=sndbx_

Breakpoints in utils.php were set for line 331:

$final_cmd = $cmd . assoc_args_to_str( $assoc_args );

which creates the final command handed to line 333 for execution:

$proc = proc_open( $final_cmd, $descriptors, $pipes );

Here's the debugging image with the status of the variables just before processing lines 334-339 to exit wp-cli and producing the failure message on the bash command line:

Boss@Bonkers /cygdrive/c/wamp/www/wpsandbox
$ ../wp-cli-0.14.1.phar core config --dbhost=127.0.0.1 --dbname=wpsandbox --dbuser=root --dbpass=Bonkers --dbprefix=sndbx_
'MYSQL_PWD' is not recognized as an internal or external command,
operable program or batch file.

Boss@Bonkers /cygdrive/c/wamp/www/wpsandbox
$ 

I know wp-cli is well constructed software so it's most likely me missing something along the way. (Getting the command line and PHPStorm working together was time consuming since it's a new tool for me.) I'll keep at it as time allows, but if someone has any clues it would help.

UPDATE: 03/29/14

Thanks for the ticket and merge scribu, but unfortunately it doesn't fix the problem. I'm getting the same error.

At first I was confused after re-downloading the phar file because I found the exact same code as before your ticket and merge. A WTF moment. So I looked at the builds directory on GitHub and see that file is dated 2 days prior to your merge so it would not have included the changes.

I grabbed the nightly, reloaded the project and there were the changes with putenv() but Bash is throwing the same error as before.

It seems since this change wp-cli has been incompatible with Cygwin.

UPDATE: 04/19/2014

Version 0.15.0 was released on 4/15 so I installed it and ran all the commands above. wp-cli worked as it did in versions < 0.14.1. I compared 0.14.1 to 0.15.0 and found the following.

Lines 326-339 of v0.14.1 read:

if ( isset( $assoc_args['pass'] ) ) {
    $cmd = esc_cmd( 'MYSQL_PWD=%s ', $assoc_args['pass'] ) . $cmd;
    unset( $assoc_args['pass'] );
}

$final_cmd = $cmd . assoc_args_to_str( $assoc_args );

$proc = proc_open( $final_cmd, $descriptors, $pipes );
if ( !$proc )
    exit(1);

$r = proc_close( $proc );

if ( $r ) exit( $r );

Lines 326-342 in v0.15.0 now read:

$pass = $assoc_args['pass'];
unset( $assoc_args['pass'] );

$old_pass = getenv( 'MYSQL_PWD' );
putenv( 'MYSQL_PWD=' . $pass );

$final_cmd = $cmd . assoc_args_to_str( $assoc_args );

$proc = proc_open( $final_cmd, $descriptors, $pipes );
if ( !$proc )
    exit(1);

$r = proc_close( $proc );

putenv( 'MYSQL_PWD=' . $old_pass );

if ( $r ) exit( $r );

This has fixed the problem. wp-cli is now working again with Cygwin, at least the commands I've used here as well as a few more that relied on getting past this point - the install.

4

It seems like Cygwin doesn't support inline environment variables, like Bash does.

Opened a ticket: https://github.com/wp-cli/wp-cli/issues/1086

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.