wp-cli: wp core download gives "unable to decompress gzipped phar archive" error
We have a nightly script that downloads and reinstalls WordPress on a testing server. Last night, it failed like this:
$ wp core --debug download
Debug (bootstrap): No readable global config found (0.067s)
Debug (bootstrap): No project config found (0.068s)
Debug (bootstrap): argv: /usr/bin/wp core --debug download (0.068s)
Debug (bootstrap): ABSPATH defined: /var/www/html/ (0.068s)
Debug (bootstrap): Running command: core download (0.069s)
Downloading WordPress 4.8.2 (en_US)...
md5 hash verified: 2e8744a702a3d9527782d9135a4c9544
Error: Couldn't extract WordPress archive. unable to decompress gzipped phar archive "/tmp/wp_59c231a7990f7.tar.gz" to temporary file
I’ve checked that I have not run out of free disk space. I have also checked that the temporary file is a valid gzipped tarball:
$ cat /tmp/wp_59c231a7990f7.tar.gz | file -
/dev/stdin: gzip compressed data, last modified: Tue Sep 19 21:21:21 2017, from Unix
$ zcat /tmp/wp_59c231a7990f7.tar.gz | file -
/dev/stdin: POSIX tar archive (GNU)
$ tar tf /tmp/wp_59c231a7990f7.tar.gz | head
wordpress/
wordpress/wp-settings.php
wordpress/wp-cron.php
wordpress/wp-comments-post.php
wordpress/wp-activate.php
wordpress/wp-admin/
wordpress/wp-admin/link-parse-opml.php
wordpress/wp-admin/js/
wordpress/wp-admin/js/editor.js
wordpress/wp-admin/js/user-profile.min.js
Here is some more debugging information:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
$ php -v
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
$ wp --version
WP-CLI 1.3.0
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 80 (47 by maintainers)
Commits related to this issue
- use wp-cli nightly fixes wordpress build see https://github.com/wp-cli/wp-cli/issues/4370#issuecomment-331160093 — committed to vintagesucks/caddy-script by vintagesucks 7 years ago
- use wp-cli nightly (#60) fixes wordpress build see https://github.com/wp-cli/wp-cli/issues/4370#issuecomment-331160093 — committed to vintagesucks/caddy-script by vintagesucks 7 years ago
- Update Vagrantfile Handle https://github.com/wp-cli/wp-cli/issues/4370 — committed to kadimi/wp.box by kadimi 7 years ago
- Update Vagrantfile See https://github.com/wp-cli/wp-cli/issues/4370#issuecomment-332245998 — committed to kadimi/wp.box by kadimi 7 years ago
Thanks everyone who spent time tracking this down. Given this isn’t an issue with WP-CLI itself but with specific PHP distros, I think we’ve fixed it the best we can.
We’ll publish WP-CLI v1.4.0 on Tuesday, October 17th. For now, those affected can use
wp cli update --nightly.If I use arg --version it works wp --allow-root core download --version=“4.8.1”
I tracked down the guilty party to here https://github.com/php/php-src/blob/master/ext/zlib/zlib_filter.c#L124 in the
zlib_filterwhere it returns without updating thebytes_consumedvariable, as if a.tar.gzis 1 to about 10 bytes over modulo 8192 then no output might be needed (the last 4 bytes are just a checksum anyway) but the bytes have been consumed, and not reporting them as such causes the calling function to error.As mentioned above this is only triggered for files > 4MB on distributions with the Debian patch but even so it’s surprising it hasn’t been noticed before.
@miya0001 Great, now it works …
Going with a workaround for the time being: https://github.com/wp-cli/wp-cli/pull/4371
If someone wants to try, here’s a Phar build: https://www.dropbox.com/s/taeh1mak9fvmlu6/wp-cli-nightly.phar?dl=0
The problem seems to be specific to gzip, not tar.
I’ve also created a meta issue for this: https://meta.trac.wordpress.org/ticket/3150
This will work
wp --allow-root core download --locale=sv_SE
The problem is with US files …
@gitlost sorry not to have replied sooner. the server is running PHP7.0 from Debian Stretch:
@ZeroX66
Nightly is the only way to have the fix. There hasn’t been a release yet.
Hm, It’s still some trouble with it. I change to this and it works with “nightly”.
wp cli update --nightly
Not yet scheduled. You should use the nightly build.
@ZeroX66 Nightly build is working for now. 😃 https://make.wordpress.org/cli/handbook/installing/#installing-nightly-via-phar
@danielbachhuber I do not have a better idea than opening a ticket on the right tracker and request to re-create the archive.
Could it be some issue with the WP archive?
wp core download --version=4.8.1 --forcesucceeds.wp core download --version=4.8.2 --forcefails.My hunch is that the WordPress US build is corrupt in some way.
I have an idea for a solution.
We could do a
try {} catch ()block within the\WP_CLI\Extractor::extract_tarball()method. We could try thePharDataclass first, but if it throws an exception we could fall back to using a command line exec to do the extraction. If that still fails, then throw an exception and let it bubble back up to the existing block.@wojsmol
That’s a good thought, but it appears that zlib is enabled:
@ZeroX66
I don’t think that line is the problem. That line is only executed if the
PharDataclass does not exist. The class does exist. The exception happens on$phar = new PharData( $tarball );as was mentioned by @miya0001So it seems that there’s some issue between the package and the
PharDataclass. I’m not sure how to determine which of them is to blame.on enviramant with error plese check if zlib php extesion is enabled reference https://github.com/composer/composer/issues/984
@ZeroX66 If you want to change default locale, you can set default locale to
~/.wp-cli/config.ymllike following.@gitlost sure
Anyway i changed the locale to it_IT and now it works.
Yes, the problem is with the US package - at least the German one runs well with
wp core download --locale=de_DEThe Swedish as well as @ZeroX66 wrote.