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

参考

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 上天给予我的 比别人多 多一分悲伤 我还给上天的 比别人少 少一颗灵魂 在人间
    illme阅读 331评论 4 3
  • 从出生到现在 做的最多的事 便是等待 等待春暖花开之后的 骄阳似火 等待天高云淡之后的 银装素裹 等待稚嫩的花朵 ...
    Alice解艳阅读 249评论 0 3
  • 【容苼】 文:洛柒笙 文案: 容苼十岁遇见了和煦 二十五岁遇见了木裴 箫青裳二十七岁遇见了容苼 他一生只为其绽放 ...
    洛柒笙阅读 247评论 0 0