composer-php - 如何修复“https://repo.packagist.org/packages.json 不包含有效的 Json”?
问题描述
我对在 vagrantbox(Centos 7)上运行的作曲家有疑问,它开始突然发生。
我已经尝试手动运行下面链接中提到的命令/解决方案,但无济于事。
(澄清一下,我使用的是 vagrant 而不是 docker,但这是我发现的最接近我的情况的问题。我发现的大部分信息都与 composer.json 无效有关,但这里是 packagist.org/packages.json其中,当前有效)
Composer 在 docker 容器中不起作用:“https://packagist.org/packages.json”不包含有效的 JSON
以下是问题的详细信息。
composer update
在终端上运行时,我得到:
composer update
[Seld\JsonLint\ParsingException]
"https://repo.packagist.org/packages.json" does not contain valid JSON
Parse error on line 1:
^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
当composer install
也在终端上运行时,每个包都会返回:
Failed to download psr/cache from dist: "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8"
appears broken, and returned an empty 200 response
Now trying to download from source
运行composer config --global repo.packagist composer packagist.org
结果是现在
composer update
Loading composer repositories with package information
[Composer\Downloader\TransportException]
Your configuration does not allow connections to http://repo.packagist.org/packages.json. See https://getcomposer.o
rg/doc/06-config.md#secure-http for details.
任何想法为什么会发生这种情况,我该如何解决?
解决方案
Could also be IPv6 related, if your provider/system is configured for IPv6 but has no valid IPv6 route out to the internet.
This happened to me, and doing
sysctl -w net.ipv6.conf.all.disable_ipv6=1
(as root), then trying composer again fixed the issue.
To permanently apply it, add the rule to /etc/sysctl.conf (or wherever your OS preferred is)
推荐阅读
- reactjs - 无法使用模块扩充覆盖模块的打字稿定义
- c# - C# 多态性 - 向上转型
- wordpress - WordPress 访问被拒绝问题
- html - 无法在 chrome 上的移动视图中取消选中复选框输入
- ios - 为什么在 Mac OS 上运行的 iPad 应用程序的安全区域没有固定在视图顶部?
- python - 在 pyqt5 中使用 plotly
- python - sqlachemy 表达式错误:(psycopg2.errors.CardinalityViolation)用作表达式的子查询返回的行不止一行
- performance - K8s & Jenkins:监控一些指标的工具
- google-colaboratory - colab pro+ 后台执行好像没有生效
- javascript - ApexCharts 柱形图标记损坏?