composer: Content-Length mismatch (again)

My composer.json:

{} // nothing, fresh install

Output of composer diagnose:

Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 1.7.3
PHP version: 7.2.10
PHP binary path: /usr/bin/php7.2

When I run this command:

composer global require cpriego/valet-linux

I get the following output:

 [Composer\Downloader\TransportException]                                    
  Content-Length mismatch, received 111539 bytes out of the expected 1617048 

And I expected this to happen: Install valet linux

Fix: #6449

Finally I fixed it by using a chinese mirror. mv composer.phar /usr/local/bin/composer composer config -g repo.packagist composer https://packagist.phpcomposer.com

From what I could dig out it appears that there is a problem with the EU mirrors (Eastern Europe to be exact) and #6449 fixed my issue.

I’ve seen in #6342 that a similar issue was fixed by tweaking the US mirrors, I’m suspecting as I’ve already mentioned that this is the same problem but for EU.

To note that this was tested with the same symptoms in Fedora 29 and Mint 19

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 11
  • Comments: 44 (9 by maintainers)

Most upvoted comments

If you are affected by this, try running:

composer config repositories.packagist.org composer https://repo-eu-uk-1.packagist.org

This should force to use the UK mirror which is hopefully unaffected by those network issues.

Accessing the mirror URL directly is kind of a hack though and not guaranteed to work in the future, so I would advise you to remove it in the coming days once this network glitch hopefully passes… You can do so using:

config repositories.packagist.org --unset

I’d appreciate if anyone can report back whether things work again (you can just 👍 this post to avoid spamming all in the thread).

As a reminder, config repositories.packagist.org --unset should undo the workaround and get you back using the default URL, which I would highly recommend to avoid issues in the future.

@Seldaek’s hack didn’t work for me. It still took ages, so I changed to a third party mirror: composer config -g repos.packagist composer https://packagist.co.za which works great. Just to let people know 😃

@RomanoschoonheimNL do you have more details? Does it fail with a timeout/content length issue like the others or is it another issue? You can also try repo-ca-bhs-1.packagist.org as an alternative to the UK node, see if it helps.