简体   繁体   中英

Composer (installing / updating) always fails

I have a stable connection, however composer always throws Composer\\Downloader\\TransportException when I run composer update on my project root, followed by messages stating that I had a timeout error while downloading the files.

After running composer diagnose , everything seems to pass the test.

I attempted uninstalling, and, afterwards, I could not install composer. When I download composer with curl -sS https://getcomposer.org/installer | php curl -sS https://getcomposer.org/installer | php , composer prints this to the stream:

 ~  curl -sS https://getcomposer.org/installer | php -d detect_unicode=Off
All settings correct for using Composer
Downloading...
Download failed: Failed to open https://getcomposer.org/composer.phar (Operation timed out after 4994 milliseconds with 229148 out of 1016883 bytes received)
Downloading...
Download failed: Failed to open https://getcomposer.org/composer.phar (Operation timed out after 4988 milliseconds with 261916 out of 1016883 bytes received)
Downloading...
SlowTimer [5000ms] at curl: https://getcomposer.org/composer.phar
Download failed: Failed to open https://getcomposer.org/composer.phar (Operation timed out after 4996 milliseconds with 147228 out of 1016883 bytes received)
The download failed repeatedly, aborting.

I am using Ubuntu 14.04 LTS .

Any ideas on why this keeps happening?

I advised on this before. Try composer update/install -o -vvv and check wether the package is being loaded from composer's cache.

if yes try clearing composer's cache or try adding -cache-dir=/dev/null .

To force downloading an archive instead of cloning sources, use the --prefer-dist option in combination with --no-dev .

Otherwise you could try raising composer's process timeout value:

export COMPOSER_PROCESS_TIMEOUT=600 ( defaults to 300 )

I'm not sure that this applies to your reinstall option, but it might apply to your initial timeout problem (in addition to the suggestions of Vector); I was using hhvm to run composer , which specifies its own request timeout parameters, which override anything that you specify in your composer.json or the environment variables. The previous link contains the appropriate information to configure your timeout in more detail, but my example bash alias may help.

alias composer='hhvm -v ResourceLimit.SocketDefaultTimeout=60 -v Http.SlowQueryThreshold=60000 -v Eval.Jit=false /home/liam/bin/composer'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM