Content-Length mismatch, received 30804 bytes out of the expected 264036 - composer

前言

今天在使用 composer 安装一个插件库的时候报错,看错误信息是缓存的字节大小限制和超时导致的。
对于不熟悉 composerphper 一定要去了解一下,为什么一定?百度会有很多人告诉你答案。
附上composer中文文档连接:composer 中文文档

错误信息

Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 7 installs, 0 updates, 0 removals
  - Installing phpseclib/phpseclib (2.0.23): Downloading (45%)
Downloading (25%)
Downloading (10%)    Failed to download phpseclib/phpseclib from dist: Content-Length mismatch, received 30804 bytes out of the expected 264036
    Now trying to download from source
  - Installing phpseclib/phpseclib (2.0.23): Cloning c78eb5058d


  [Symfony\Component\Process\Exception\ProcessTimedOutException]
  The process "git clone --no-checkout "https://github.com/phpseclib/phpseclib.git" "E:\workspace\elastic_search\vendor\phpseclib\phpseclib" 
&& cd /D "E:\workspace\elastic_search\vendor\phpseclib\phpseclib" 
&& git remote add composer "https://github.com/phpseclib/phpseclib.git" 
&& git fetch composer" exceeded the timeout of 300 seconds.

一般跟超时有关的就是源的问题,这里需要更换一下源地址就好了

解决方法

  1. 更换阿里云的 composer 源(亲测可用)
composer config repo.packagist composer https://mirrors.aliyun.com/composer/

reporepositories 的简写方式
上面的命令值针对当前的项目有效,如果需要设置全局的在config后面加 -g--global

注意:
   如果是只是因为超过缓存的大小,那只需要将缓存大小修改一下就好了
   修改命令:composer config cache-files-maxsize 800MiB

参考

  • 【已解决】Content-Length mismatch, received 15988 bytes out of the 问题
  • composer Content-Length mismatch

你可能感兴趣的:(Content-Length mismatch, received 30804 bytes out of the expected 264036 - composer)