Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli update failes on windows with message "error:cannot move ..." #5800

Open
Speed4Trade-Admin opened this issue Jun 5, 2023 · 2 comments
Open

Comments

@Speed4Trade-Admin
Copy link

Speed4Trade-Admin commented Jun 5, 2023

When I try to update wp-cli.phar on windows, I get an error message that the temp file cannot be moved.

Command:
php.exe "C:\Program Files\wp\wp-cli.phar" cli update

Output:

You have version 2.8.0. Would you like to update to 2.8.1? [y/n] y
Downloading from https://github.com/wp-cli/wp-cli/releases/download/v2.8.1/wp-cli-2.8.1.phar...
md5 hash verified: a0cf91756fd46903c83c436ec1d462eb
New version works. Proceeding to replace.
Error: Cannot move C:\Users\xxx\AppData\Local\Temp\3/wp_647daad3256960.42338796.phar to C:\Program Files\wp\wp-cli.phar

The slash seems suspicious on windows and might be a possible reason (?)

Permissions are ok, I can move the file manually on cmd if I replace the / with \.
On the same console session, the command "cli update" fails however.

@Speed4Trade-Admin
Copy link
Author

Speed4Trade-Admin commented Jun 5, 2023

The slash doesn't matter.
I tested with a test.php and renamed the file successfully.
Not sure if a handle prevents the renaming or the cli can't replace itself (?)

@danielbachhuber
Copy link
Member

Thanks for the report, @Speed4Trade-Admin

The slash doesn't matter.
I tested with a test.php and renamed the file successfully.

Can you share what commands you ran here? The slash is suspicious to me too. Here's where it's added:

$temp = trailingslashit( sys_get_temp_dir() );

wp-cli/php/utils.php

Lines 1008 to 1023 in ad16e53

/**
* Appends a trailing slash.
*
* @access public
* @category System
*
* @param string $string What to add the trailing slash to.
* @return string String with trailing slash added.
*/
function trailingslashit( $string ) {
if ( ! is_string( $string ) ) {
return '/';
}
return rtrim( $string, '/\\' ) . '/';
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants