composer 执行install 超时解决

我本地的环境是docker,进入docker执行install后返回超时:

# composer install
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information

In CurlDownloader.php line 365:
                                                                               
  curl error 28 while downloading https://asset-packagist.org/p/provider-late  
  st/bc3c38a4ad0b2cfc183fe5862cccd5fd09bbe0feee20509b4a7dd7665ca92870.json: O  
  peration timed out after 300000 milliseconds with 3489544 out of 10490676 b  
  ytes received                                                                
                                                                               

install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]

 现在,先试着换镜像试试:

# composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

 问题并没有解决,执行composer自检命令:

# composer diagnose
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK git version 2.30.2
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: FAIL
[Composer\Downloader\TransportException] curl error 28 while downloading https://repo.packagist.org/packages.json: Operation timed out after 10001 milliseconds with 0 out of 0 bytes received
Checking github.com rate limit: OK
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: You are not running the latest stable version, run `composer self-update` to update (2.5.2 => 2.5.4)
Composer version: 2.5.2
PHP version: 7.4.33
PHP binary path: /usr/local/bin/php
OpenSSL version: OpenSSL 1.1.1n  15 Mar 2022
cURL version: 7.74.0 libz 1.2.11 ssl OpenSSL/1.1.1n
zip: extension not loaded, unzip present, 7-Zip not available

 提示composer版本不是最新版,所以更新下:

# composer self-update
Upgrading to version 2.5.4 (stable channel).
   
Use composer self-update --rollback to return to version 2.5.2

 重新执行composer自检命令:

# composer diagnose
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK git version 2.30.2
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
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
Composer version: 2.5.4
PHP version: 7.4.33
PHP binary path: /usr/local/bin/php
OpenSSL version: OpenSSL 1.1.1n  15 Mar 2022
cURL version: 7.74.0 libz 1.2.11 ssl OpenSSL/1.1.1n
zip: extension not loaded, unzip present, 7-Zip not available

 返回错误:

In CurlDownloader.php line 365:
                                                                               
  curl error 28 while downloading https://packagist.org/providers/bower-asset  
  /inputmask.json: Operation timed out after 10005 milliseconds with 0 out of  
   0 bytes received  

访问超时或操作超时,到达指定的超时期限条件。

使用 -vvv 发现 curl 有一个文件  https://asset-packagist.org/p/provider-latest/xxx.json 下载失败了

 

解决方法是修改composer.json

将 https://asset-packagist.org 改为

https://asset-packagist.cn

 

再执行 composer install 就成功了!

posted @ 2023-02-17 20:37  sunyheart  阅读(1865)  评论(0编辑  收藏  举报