安装 Laravel 时作曲家错误“无法解码响应:zlib_decode():数据错误”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33501240/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:08:36  来源:igfitidea点击:

Composer Error while installing Laravel "Failed to decode response: zlib_decode(): data error"

laravellaravel-5composer-php

提问by MKJ

I've already installed laravel a lot of times, but today when I had to install it for my project I experienced the following strange error:

我已经安装了 Laravel 很多次了,但是今天当我不得不为我的项目安装它时,我遇到了以下奇怪的错误:

Failed to decode response: zlib_decode(): data error
Retrying with degraded mode

I ran the following command to install laravel:

我运行以下命令来安装 Laravel:

composer create-project laravel/laravel myproject --prefer-dist

in my /var/www/directory which is totally read, write and executable.

在我的/var/www/目录中,它是完全可读、可写和可执行的。

回答by Medmo

Try the following command:

尝试以下命令:

composer clear-cache

回答by dwainm

Add this lines to " composer.json " before the last line that conten this symbol " } "

将此行添加到“ composer.json ”中包含此符号“ } ”的最后一行之前

,
"repositories": [
{
"type": "composer",
"url": "https://packagist.org"
},
{ "packagist": false }
]

Now cd to your project folder and type :

现在 cd 到您的项目文件夹并键入:

Composer install

Credits to: http://www.webdeveloper.com/forum/showthread.php?285403-Need-Help-Installing-Laravel

归功于:http: //www.webdeveloper.com/forum/showthread.php?285403-Need-Help-Installing- Laravel

回答by David Lukac

Short:Run composer self-update --update-keysand follow instructions.

简短:运行composer self-update --update-keys并按照说明进行操作。



Step by step:

一步步:

I had the same error when trying to install dependencies for my project:

尝试为我的项目安装依赖项时遇到了同样的错误:

Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
Your configuration does not allow connection to http://packagist.org. See https://getcomposer.org/doc/06-config.md#secure-http for details.
http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date

Just to be sure, I tried to update the composer with composer self-update, which gave me the same error, but another hint:

可以肯定的是,我尝试用 更新作曲家composer self-update,这给了我同样的错误,但另一个提示:

[RuntimeException]
The phar signature did not match the file you downloaded, this means your public keys are outdated or that the phar file is corrupt/has been modified

The issues is solved by running

问题通过运行解决

composer self-update --update-keys

and entering the keys from Composer Public Keys / Signaturespage. I was able to download my dependencies afterwards.

并从Composer Public Keys / Signatures页面输入密钥。之后我能够下载我的依赖项。

回答by codingdaddy

In my case, the version of VirtualBox was the issue. https://github.com/composer/composer/issues/5814

就我而言,VirtualBox 的版本是问题所在。 https://github.com/composer/composer/issues/5814

Make sure that your VB is not 5.0.28 or 5.1.8.

确保您的 VB 不是 5.0.28 或 5.1.8。

回答by oussaka

install or update the library after running

运行后安装或更新库

composer config --global repositories.packagist.allow_ssl_downgrade false

回答by j0k

Following what @dwainm says, you can also define this configuration globally to avoid editing the composer.jsonfrom your project.

按照@dwainm 所说的,您还可以全局定义此配置,以避免composer.json从您的项目中编辑。

Create a ~/.composer/config.jsonwith:

创建一个~/.composer/config.json

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://packagist.org"
        },
        {
            "packagist": false
        }
    ]
}

回答by orrd

If you look at the answers people come up with this, there are a wide variety of things that fixed it for various people, including using "sudo", using "self-update", etc etc.

如果您查看人们提出的答案,就会发现为不同的人修复了很多问题,包括使用“sudo”、使用“自我更新”等。

After a lot of testing, I found that the real answer is to just keep on running it over and over again. It gets a little farther each time, and caches the previous data that it was able to get the last time. So eventually it just works, and then people think that the last thing they did is what solved it. In reality you just have to run it over and over. This is clearly something that composer should fix.

经过大量测试,我发现真正的答案是继续一遍又一遍地运行它。它每次都走得更远一些,并缓存它上次能够获得的先前数据。所以最终它就起作用了,然后人们认为他们做的最后一件事就是解决了它。实际上,您只需要一遍又一遍地运行它。这显然是作曲家应该解决的问题。

The key to seeing that it is making progress each time you run it is to use

每次运行它时看到它都在取得进展的关键是使用

composer update -vvv

作曲家更新 -vvv

That will show you how far it got with the last time you ran it. Each time you run it, it will usually download another repo or two.

这将显示您上次运行它的距离。每次运行它时,它通常会下载另一个或两个存储库。

Until composer fixes whatever the underlying cause is, that appears to be the best solution. Good luck.

在 composer 修复任何根本原因之前,这似乎是最好的解决方案。祝你好运。

回答by Carlos Pereira

I'll leave this answer to those like me have tried all of the above solutions do not succeed. In my case the problem was related version of Virtual Box (1.5.8) for Mac. I did downgrade my previous version (1.5.2) and all returned to work properly.

我会把这个答案留给像我这样尝试过所有上述解决方案的人都没有成功。就我而言,问题出在 Mac 的 Virtual Box (1.5.8) 相关版本上。我确实降级了我以前的版本 (1.5.2),并且一切都恢复了正常工作。

回答by Sam T

Quick fix from composer

作曲家的快速修复

Degraded Mode#

降级模式#

Due to some intermittent issues on Travis and other systems, we introduced a degraded network mode which helps Composer finish successfully but disables a few optimizations. This is enabled automatically when an issue is first detected. If you see this issue sporadically you probably don't have to worry (a slow or overloaded network can also cause those time outs), but if it appears repeatedly you might want to look at the options below to identify and resolve it.

由于 Travis 和其他系统上的一些间歇性问题,我们引入了降级网络模式,该模式有助于 Composer 成功完成但禁用了一些优化。首次检测到问题时会自动启用此功能。如果您偶尔看到此问题,您可能不必担心(缓慢或过载的网络也可能导致这些超时),但如果它反复出现,您可能需要查看下面的选项来识别和解决它。

If you have been pointed to this page, you want to check a few things:

如果您已被指向此页面,您需要检查以下几点:

If you are using ESET antivirus, go in "Advanced Settings" and disable "HTTP-scanner" under "web access protection" If you are using IPv6, try disabling it. If that solves your issues, get in touch with your ISP or server host, the problem is not at the Packagist level but in the routing rules between you and Packagist (i.e. the internet at large). The best way to get these fixed is raise awareness to the network engineers that have the power to fix it.

如果您使用的是 ESET 防病毒软件,请进入“高级设置”并禁用“Web 访问保护”下的“HTTP 扫描程序”。如果您使用的是 IPv6,请尝试禁用它。如果这解决了您的问题,请联系您的 ISP 或服务器主机,问题不在于 Packagist 级别,而在于您和 Packagist 之间的路由规则(即整个互联网)。修复这些问题的最佳方法是提高对有能力修复它的网络工程师的认识。

To disable IPv6 on Linux, try using this command which appends a rule preferring IPv4 over IPv6 to your config:

要在 Linux 上禁用 IPv6,请尝试使用此命令,该命令将优先使用 IPv4 而非 IPv6 的规则附加到您的配置中:

sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"

sudo sh -c "echo '优先级 ::ffff:0:0/96 100' >> /etc/gai.conf"

If none of the above helped, please report the error.

如果以上都没有帮助,请报告错误。

回答by parker_codes

This may seem redundant, but try restarting your machine. If you've just installed composer and other things, then your system may just need to be refreshed..

这似乎是多余的,但请尝试重新启动您的机器。如果您刚刚安装了 composer 和其他东西,那么您的系统可能只需要刷新..

I was having this same issue, but it is now working correctly after a restart (on Mac).

我遇到了同样的问题,但它现在在重新启动后正常工作(在 Mac 上)。