Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer: "Content-length mismatch" & "http://packagist.org could not be fully loaded..."

When I try to create a new laravel project with "laravel new project" I got this error:

Content-Length mismatch
http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date

When I do "composer update" or "composer install doctrine/dbal", I got the error too. And my composer is too slow.

like image 297
Chung Avatar asked Oct 28 '16 16:10

Chung


3 Answers

Just note useful information for this error: This is a network error regarding ipv6. I can't know exactly what causes it. But we can fix it through a workaround solution

Workaround Linux: Run command

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

Workaround Windows:

On windows, the only way is to disable ipv6 entirely I am afraid (either in windows or in your home router).

Workaround Mac OS X: Get the 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

That said, if this fixes your problem, please talk to your ISP about it to try to resolve the routing errors. That's the best way to get things resolved for everyone.

Refer to this article: https://getcomposer.org/doc/articles/troubleshooting.md#operation-timed-out-ipv6-issues-

like image 57
Vincent Le Avatar answered Sep 19 '22 14:09

Vincent Le


clear the composer cache with the following command:

composer clear-cache
like image 45
Samir Rahimy Avatar answered Sep 16 '22 14:09

Samir Rahimy


I got this same error and solved it only changing the http protocol in composer repository config with https:

composer config -g repo.packagist composer https://packagist.org
like image 43
Pegasus Avatar answered Sep 16 '22 14:09

Pegasus