composer: curl error 23 when updating custom repository
Edit: How to Fix
Run brew reinstall curl
to get the latest curl and fix this issue
Hi,
from yesterday composer started giving me this error when I’m using a custom repository:
curl error 23 while downloading https://<private-repo-url>/packages.json: Failed writing received data to disk/application
After many tries to fix this problem, I found that removing this line from CurlDownloader
fixes the problem:
curl_setopt($curlHandle, CURLOPT_ENCODING, ""); // let cURL set the Accept-Encoding header to what it supports
I encountered this problem only on my mac, I tried with docker and it works.
Output of composer diagnose
:
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK git version 2.44.0
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK does not expire
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0 87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B 0C708369 153E328C AD90147D AFE50952
OK
Checking Composer version: OK
Checking Composer and its dependencies for vulnerabilities: OK
Composer version: 2.7.2
PHP version: 8.3.4
PHP binary path: /opt/homebrew/Cellar/php/8.3.4/bin/php
OpenSSL version: OpenSSL 3.2.1 30 Jan 2024
cURL version: 8.7.1 libz 1.2.12 ssl (SecureTransport) OpenSSL/3.2.1
zip: extension present, unzip present, 7-Zip not available
When I run this command:
composer update --no-cache -v
I get the following output:
Loading composer repositories with package information
In CurlDownloader.php line 389:
[Composer\Downloader\TransportException]
curl error 23 while downloading https://<private-repo-url>/packages.json: Failed writing received data to disk/application
Exception trace:
at phar:///usr/local/bin/composer/src/Composer/Util/Http/CurlDownloader.php:389
Composer\Util\Http\CurlDownloader->tick() at phar:///usr/local/bin/composer/src/Composer/Util/HttpDownloader.php:392
Composer\Util\HttpDownloader->countActiveJobs() at phar:///usr/local/bin/composer/src/Composer/Util/HttpDownloader.php:363
Composer\Util\HttpDownloader->wait() at phar:///usr/local/bin/composer/src/Composer/Util/HttpDownloader.php:114
Composer\Util\HttpDownloader->get() at phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php:1486
Composer\Repository\ComposerRepository->fetchFile() at phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php:1195
Composer\Repository\ComposerRepository->loadRootServerFile() at phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php:823
Composer\Repository\ComposerRepository->hasProviders() at phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php:484
Composer\Repository\ComposerRepository->loadPackages() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/PoolBuilder.php:401
Composer\DependencyResolver\PoolBuilder->loadPackagesMarkedForLoading() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/PoolBuilder.php:251
Composer\DependencyResolver\PoolBuilder->buildPool() at phar:///usr/local/bin/composer/src/Composer/Repository/RepositorySet.php:326
Composer\Repository\RepositorySet->createPool() at phar:///usr/local/bin/composer/src/Composer/Installer.php:495
Composer\Installer->doUpdate() at phar:///usr/local/bin/composer/src/Composer/Installer.php:292
Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:251
Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:298
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:1040
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:301
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:385
Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:171
Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:145
Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:93
require() at /usr/local/bin/composer:29
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Comments: 25 (3 by maintainers)
Commits related to this issue
- Workaround curl bug in 8.7.0/8.7.1, fixes #11913 — committed to carlos-granados/composer by Seldaek 2 months ago
After running
brew reinstall curl
on my machine, it seems the error disappear.This is a curl regression in https://github.com/curl/curl/commit/463472a2d6e3301c1468b5323b856cb67a91f579 meaning curl 8.7.0 and 8.7.1 are affected. 8.7.2 is planned to be released on May 22, 2024.
As that’s kinda far off, and it seems to affect a bunch of people… I tried to publish a workaround. Can someone affected please try if
composer self-update --snapshot
resolves it? I am not sure if hardcoding the Accept-Encoding header togzip
fixes it as well or if we really need to disable compression altogether.Once confirmed I’ll try to get a release out…
@mpociot Is there also a fix when using
herd composer
? I guess that requires a new release for the PHP binary?For those of you who are curious why a
brew reinstall
fixes the issue despite no new version of curl being released: Homebrew manually applies this patch, which fixes the issue: https://github.com/curl/curl/commit/b30d694a027eb771c02a3db0dee0ca03ccab7377I’ve been having this problem for a week and I couldn’t solve it. I cannot update curl on the server where Whm is installed. Do you have a different solution suggestion?