composer/composer · critical · RuntimeException
Failed to execute {command} {errorOutput}
Error message
Failed to execute {command}
{errorOutput} What it means
Thrown by GzipDownloader::extract() on non-Windows when the shell command `gzip -cd` fails AND the PHP zlib extension is not loaded. On non-Windows Composer first tries the system gzip binary; only if that fails does it fall back to ext-zlib. With neither available, extraction is impossible.
Source
Thrown at src/Composer/Downloader/GzipDownloader.php:47
$targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
// Try to use gunzip on *nix
if (!Platform::isWindows()) {
$command = ['sh', '-c', 'gzip -cd -- "$0" > "$1"', $file, $targetFilepath];
if (0 === $this->process->execute($command, $ignoredOutput)) {
return \React\Promise\resolve(null);
}
if (extension_loaded('zlib')) {
// Fallback to using the PHP extension.
$this->extractUsingExt($file, $targetFilepath);
return \React\Promise\resolve(null);
}
$processError = 'Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput();
throw new \RuntimeException($processError);
}
// Windows version of PHP has built-in support of gzip functions
$this->extractUsingExt($file, $targetFilepath);
return \React\Promise\resolve(null);
}
private function extractUsingExt(string $file, string $targetFilepath): void
{
$archiveFile = gzopen($file, 'rb');
$targetFile = fopen($targetFilepath, 'wb');
while ($string = gzread($archiveFile, 4096)) {
fwrite($targetFile, $string, Platform::strlen($string));
}
gzclose($archiveFile);
fclose($targetFile);
}View on GitHub (pinned to 6ffc117740)
Solutions
- Install gzip in the environment: apt-get install -y gzip (or apk add gzip on Alpine).
- Enable/install the PHP zlib extension (ext-zlib) so the PHP fallback works.
- Use a PHP image that ships ext-zlib (most official images do).
- Prefer dist formats that use XzDownloader/TarDownloader if the provider offers non-gzip archives.
Example fix
# before: neither gzip nor ext-zlib available composer install # GzipDownloader fails # after: install gzip apt-get update && apt-get install -y gzip # or ensure ext-zlib in PHP: docker-php-ext-install zlib # rebuild PHP with zlib
Defensive patterns
Strategy: validation
Validate before calling
// Verify gzip binary or ext-zlib before relying on GzipDownloader
$hasGzip = false === stripos(PHP_OS_FAMILY, 'Windows')
? (function_exists('shell_exec') ? (bool) trim((string) shell_exec('command -v gzip')) : false)
: true; // Windows uses ext-zlib path
$hasZlib = extension_loaded('zlib');
if (!$hasGzip && !$hasZlib) {
throw new \RuntimeException('No gzip extraction method available: install gzip or enable ext-zlib');
} Prevention
- In Docker/CI images, install the gzip package (apk add gzip / apt-get install gzip).
- Build PHP with --enable-zlib so the extension-level fallback is always present.
- Prefer dist formats other than raw .gz where the provider offers tar.xz or zip.
When it happens
Trigger: Installing a package whose dist is a .gz single-file archive (not a tar/zip) on a minimal Linux image that lacks the gzip binary and where PHP was compiled without --enable-zlib.
Common situations: Minimal Alpine/Docker images without gzip installed; PHP images built without ext-zlib; stripped-down CI runners.
Related errors
- Could not decompress the archive, enable the PHP rar extensi
- The zip extension and unzip/7z commands are both missing, sk
- Can not compress to %s format
- The Zip Util requires PHP's zip extension
- You must enable the openssl extension to use a secure proxy.
AI-assisted analysis of composer/composer@6ffc117740 (2026-08-07).
Data as JSON: /api/errors/65580ef32f89f399.
Report an issue: GitHub.