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

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:
Failed to decode response: zlib_decode(): data error
Retrying with degraded mode
I ran the following command to install laravel:
composer create-project laravel/laravel myproject --prefer-dist
in my /var/www/ directory which is totally read, write and executable.

Try the following command:
composer clear-cache

Add this lines to " composer.json " before the last line that conten this symbol " } "
,
"repositories": [
{
"type": "composer",
"url": "https://packagist.org"
},
{ "packagist": false }
]
Now cd to your project folder and type :
Composer install
Credits to:
http://www.webdeveloper.com/forum/showthread.php?285403-Need-Help-Installing-Laravel

Short: Run composer self-update --update-keys and follow instructions.
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:
[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 / Signatures page. I was able to download my dependencies afterwards.

In my case, the version of VirtualBox was the issue.
https://github.com/composer/composer/issues/5814
Make sure that your VB is not 5.0.28 or 5.1.8.

Following what #dwainm says, you can also define this configuration globally to avoid editing the composer.json from your project.
Create a ~/.composer/config.json with:
{
"repositories": [
{
"type": "composer",
"url": "https://packagist.org"
},
{
"packagist": false
}
]
}

install or update the library after running
composer config --global repositories.packagist.allow_ssl_downgrade false

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.
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
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.

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.
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.
To disable IPv6 on Linux, try using this command which appends a rule preferring IPv4 over IPv6 to your config:
sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"
If none of the above helped, please report the error.

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.

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..
I was having this same issue, but it is now working correctly after a restart (on Mac).

There are many answers to this question because there are a variety of factors that could be causing this issue. It basically comes down to 1) a caching issue, 2) a connection issue to your repository (e.g. Packagist), or 3) a config issue with your Composer project.
Before you reconfigure your entire setup, eliminate options 1 and 2 first. For example, on May 23, 2017 Packagist was having issues, so switching to a different mirror solved the issue for me.

in Linux i used sudo before 'composer update' and problem solved.
sudo composer update

composer clear-cache
sudo composer self-update

Use the command composer clear-cache to clear composer cache. Also, make sure you have access to your .composer directory. It is usually located in ~/.composer.

Check that you have ZIP extension installed for your PHP CLI
for me helped(ubuntu): sudo apt-get install php7.0-zip

here is the correct way of installation of composer for slim.
1.start the composer installer (composerSetup.exe)
note: if no php.exe file is selected by default, then go to the folder of your installation (wamp, xamp, lamp -your choice of installation) folder and under bin folder, look for php\php.exe - which happens to be your command-line php for slim.
2.start the wamp, xamp or lamp (of your choice) server (to avoid the error "failed to decode zlib stream" )
3. then proceed with the rest of the installation(which will eventually lead to completion of installation with no user input required further).

I ran in the same issue while trying to composer install doctrine/dbal
This message kept showing: Failed to decode response: zlib_decode(): data error
I had to update my composer.json by adding the following lines:
{
...
"config": {
"http": true
}
...
}
And it fixed the problem. I hope it will help some of you.

For me, this error disappears when I switch off my VPN (ExpressVPN). The other methods suggested here did not work.

In my case, the issue was caused by bad file permissions in my ~/.composer directory.
So I ran
sudo chown myusername:myusername ~/.composer
(replacing myusername with my actual user name)
Then composer ran fine.

in window i used this cmd
php composer.phar clear-cache

Workaround Mac OS X:
Get name of your network device:
networksetup -listallnetworkservices
Disable IPv6 on that device (in this case "Wi-Fi"):
networksetup -setv6off Wi-Fi
Run composer ...
You can enable IPv6 again with:
networksetup -setv6automatic Wi-Fi

From Composer documentation:
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.
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. Take
a look at the next section for IPv6 workarounds.
SOLUTION FOR LINUX:
To disable ipv6, you have to open /etc/sysctl.conf using any text editor and insert the following lines at the end:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

I have been facing a similar problem. Writing the given lines in your composer.json files and then run composer update following the next composer command. Hope it helps someone as it does to me.
"repositories": [
{
"type": "composer",
"url": "https://packagist.org"
},
{ "packagist": false }
]

For Windows 10
According to TroubleShooting Composer as stated by other answers also for other OS, this may happen due to ipv6. If we disable it for all tunnels, it gets solved in Windows 10.
To disable ipv6 in Windows:
Download EasyFix file from Microsoft Support and follow the steps as stated there:
Click the Download button for the procedure that you want to run.
Click Run or Open in the File Download dialog box.
Follow the steps in the easy fix wizard.
Note: I downloaded Disable IPv6 on all tunnel interfacesversion and ran it. Then I could use composer create-project command.

Try composer clear-cache and then turn off your windows firewall

For linux ubuntu 20.04
try these step by step:
0-go to home by command "**cd ~**"
1-**composer clear-cache**
2-remove old version of composer (1.x.x) if exists "**sudo rm -R ~/.config/composer**"
3-change your internet connection(cable or wifi or ...)(important)
4-install new version with these commands...
4-1: **sudo apt update**
4-2: **sudo apt install php-cli unzip**
4-3: **sudo apt install curl**
4-4: **cd ~**
4-5: **curl -sS https://getcomposer.org/installer -o composer-setup.php**
4-6: **HASH=`curl -sS https://composer.github.io/installer.sig`**
4-7: **php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"**
4-8: **sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer**
4-9: check composer version with "**composer --version**"
if return composer 1.x.x, check this:
php /usr/local/bin/composer
if return 2.x.x, you must find your composer that installed locally and delete its folder.
Do Not Remove this folder /usr/local/bin/composer

For myself, I just made
sudo apt-get upgrade composer

Related

enable ldap module in laravel homestead

Currently have an issue where i can not enable the ldap module in homestead. I have changed multiple php.ini files and still nothing seems to be working. Has anyone else had issues with enabling modules in homestead?
Side note: when trying to restart php-fpm i am getting a permission denied issue. They prompt me with a password (which i have tried "secret") but still cant seem to get that to work either.
Have restarted the homestead instance multiple times as well. no prevail.
any thoughts?
Citti
I think this question deserves its own answer as it's pretty easy to install the wrong version of ldap on homestead and not know why things aren't working.
TL;DR: Match the version of ldap to the version of php you're running & install with apt-get.
For example, running homestead v.6.1.0:
cd HOMESTEADFOLDER # on your host
vagrant ssh # access the guest machine
sudo apt-get update # update apt-get package list
sudo apt-get install php7.1-ldap # or whatever version
In my example above, if you switch out php7.1-ldap for php7.0-ldap everything appears to install correctly (it does in fact install correctly) but, in reality, you've installed the module to a version of php that's not actually running. It took me several attempts at rebooting FPM to figure out this is what I had done.
Side note: apt-get will restart php and reload modules so there's no need to try and reboot the server or mess about with .ini files.
While ssh-ed in to the guest machine, you can check that the package is installed with php -m
If ldap is a thing your project needs, it's probably a better idea to handle this in a script. The answer referenced by fh-jashmore in his comment above comment has a simple but solid example: How to automatically enable php extensions in Homestead on vagrant up

Unable to determine why composer install is failing

I'm unable to determine why composer is failing in this ci build. It simply fails the build with no indication as to what the problem was. I've looked into -v to increase the verbosity and that has the same output at the end.
What should I try to debug this?
Composer will fail if its reaches a memory limit.
This seems to be a current trouble being discussed by the composer contributors...
You can find some issues about it on GitHub.
To face this problem, you have different solutions to try :
docker exec -it $(docker-compose ps -q sh -c cli) composer install --no-interaction --prefer-dist
If it doesn't seem to come from docker, try to see if your PHP configuration is fine :
Ensure PHP's xdebug extension is disabled for the PHP command-line version
Check if your composer.lock file is commited (it should!)
run composer with options -vvv --profile to know a bit more about the problem
As recommended by some composer contributors, get started with PHP-HHVM
If any of this is not enough, and you cannot fix it even knowing what is the memory-leak cause with -vvv option, well then maybe check either your PHP's memory_limit option or system RAM option, if it is possible for you (but it is still kind of a non-solution in my opinion) :
Maybe extend the system's memory allowed (swap file or alternatives)
Maybe install more RAM memory on the machine (worst solution in my opinion)

Installing Blackfire prob issue

Having some issue trying to get Blackfire.io set up on my homestead box.
Followed the installation guide a couple of times now, and no having no errors.
When I try to use the chrome companion I get the follow error ...
Are you authorized to profile this page? Probe not found, invalid signature
Also when I try to check out what version of the prob I am using via php --ri blackfire I get the follow message despite installing it as per the guide
Extension 'blackfire' not present.
Any ideas!?
Many thanks!
in my case (i'm using vagrant) this helped:
in file
/etc/php5/mods-available/blackfire.ini
add
extension=blackfire.so
In my case, I had to check the black-fire agent status, and when I found out it was not active I restart it and it works fine.
To check the status:
sudo /etc/init.d/blackfire-agent status
To restart :
sudo /etc/init.d/blackfire-agent restart
I had the same problem when installing blackfire probe as mentionned in the official documentation. And here is how i solved it.
Since I am using MAMP's php in my terminal i installed the PHP Probe manually instead of installing it with homebrew.
In fact in the first place i tried to instal it with homebrew and that's how i get the same error as you :
When i run this command :
php --ri blackfire
I get :
Extension 'blackfire' not present.
To fix this issue i had to install the probe manually by following theses steps:
download the probe library as mentionoed in the blackfire doc
You should have a file like this : blackfire-php-**********.so
rename it to: blackfire.so
execute this command in your terminal, it should tell you where you can put the downloaded file:
php -i | grep 'extension_dir'
move the blackfire.so file to the mentionned directory.
Close all your terminal windows and restart mamp
Execute php -m in your terminal; if you can see blackfire in the list that means that your extension is working correctly.

MariaDB homebrew install errors

I have just installed MariaDB via homebrew on my Mac. At the end of the installation I got the following error:
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall mariadb`
If I run brew postinstall mariadb I get:
==> /usr/local/Cellar/mariadb/5.5.34/bin/mysql_install_db --verbose --user=andrew --basedir=/usr/loca
MariaDB is hosted on launchpad; You can find the latest source and
email lists at http://launchpad.net/maria
Please check all of the above before mailing us! And remember, if
you do mail us, you should use the /usr/local/Cellar/mariadb/5.5.34/scripts/mysqlbug script!
READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting
Which isn't helpful! The tutorial I was following told me to run unset TEMPDIR, then mysql_install_db --user=mysql --basedir=$(brew --prefix mariadb); running those results in the following:
/usr/local/opt/mariadb/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2)
Fatal error in defaults handling. Program aborted
chown: ./data: Operation not permitted
Cannot change ownership of the database directories to the 'mysql'
user. Check that you have the necessary permissions and try again.
I suspect the problem has something to do with the /usr/local/etc/my.cnf.d folder. I've seen this referred to in a couple of things I've tried, but it doesn't exist on my machine. I have tried a few different mysql_install_db commands I've found in other tutorials, but they all throw up a (different) error message.
Thanks for any help!
Just open the config file at /usr/local/etc/my.cnf with your editor and comment out the following line:
!includedir /usr/local/etc/my.cnf.d
Having been unsuccessful with further Googling of the problem I tried manually creating a /usr/local/etc/my.cnf.d and now the mysql_install_db command seems to have worked okay. I'm not sure if this is the appropriate solution or if my.cnf.d not existing is indicative of a deeper problem with the install but, as things seem to be working, I'll mark as resolved.
[Update] As I was a little unsure in my answer whether this was the 'correct' solution I just wanted to confirm that, after a month, everything is still working fine.
None of the solution here helped, I had to do this:
The post-install step did not complete successfully MySQL Mac OS Sierra
in short,
I made a backup of the folder /usr/local/var/mysql , then removed it
removed Mariadb brew remove mariadb
reinstalled Mariadb brew install mariadb
run brew services start mariadb
After that I could access with mysql -u root
You might have an orphaned configuration file. I was able to solve this problem by deleting an old /usr/local/etc/my.cnf. YMMV.
If you're having this problem in 2021
This worked for me:
sudo mysql_install_db
sudo chown -R <YOUR USER NAME HERE> /usr/local/mysql # for example sudo chown -R jperez /usr/mysql
sudo chgrp -R admin /usr/local/mysql
After that, running mysql or mariadb will show the database prompt.
This problem seems to have recently gone away.
A simple bew upgrade resolved the problem for me.
You may want to go
/usr/local/mysql
and delete the old MySQL file and install again

Failed to open stream: HTTP request failed while trying to run 'php.exe composer.phar install'

My english is not very good, so I want to say sorry now. I'll try my best.
I wanted to try Zend Framework2. I found this link http://framework.zend.com/downloads/skeleton-app and decided to try it. After that, I downloaded repository with example application https://github.com/zendframework/ZendSkeletonApplication to C:\Sites\zf2\www. Guide says, that I need to open windows cmd and run some commands.
php.exe composer.phar self-update
php.exe composer.phar install
First opened ok and I checked for updates. But when I run install command I got this error:
10053 An established connection was aborted by the software in your host machine can't download zend
I thought that windows firewall or KIS may block it, turn them off, but nothing happened. I still can't run this command.
How can I solve this problem?
Thank you.
Sorry for my bad english.
add 1:
composer.phar passing all tests, so there are no problem with it
C:\Sites\zf2\www>php.exe composer.phar diag
Checking platform settings: OK
Checking http connectivity: OK
Checking composer.json: Ok
Checking disk free space: OK
Checking composer version: OK
add 2:
May be there are no problems with composer.phar and some programm blocks this connection?
I tried to connect directly to internet (I use router) - same error.
Also, I turned off KIS firewall and windows firewall - same result.
What can block it?
I had the same issue and after much frustration I nailed it down to a filtering software called "k9 web protection". It didn't help if I disabled the filter, I had to uninstall it.
I tried it on a few computers and the results were all the same. On 32 bit windows there was no issue but on 64 bit windows I had to uninstall k9, otherwise I continued getting this error.

Resources