Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file could not be downloaded: failed to open stream: HTTP request failed! #5286

Closed
moisespsena opened this issue May 5, 2016 · 5 comments
Closed
Labels

Comments

@moisespsena
Copy link

I'm having the below error when installing any package:

When I run this command:

$ composer -vvv require lastguest/mu

I get this output:

Running 1.0.3 (2016-04-29 16:30:15) with PHP 5.6.17-0+deb8u1 on Linux / 3.16.0-4-686-pae
Reading ./composer.json
Loading config file /home/moi/.composer/config.json
Loading config file /home/moi/.composer/auth.json
Loading config file ./composer.json
Checking CA file /etc/ssl/certs/ca-certificates.crt
Executing command (/home/moi/public_html/crudkit/tmp): git branch --no-color --no-abbrev -v
Reading /home/moi/.composer/composer.json
Loading config file /home/moi/.composer/config.json
Loading config file /home/moi/.composer/auth.json
Loading config file /home/moi/.composer/composer.json
Loading config file /home/moi/.composer/auth.json
Downloading https://packagist.org/packages.json
Writing /home/moi/.cache/composer/repo/https---packagist.org/packages.json into cache
Reading /home/moi/.cache/composer/repo/https---packagist.org/p-provider-2013.json from cache
Reading /home/moi/.cache/composer/repo/https---packagist.org/p-provider-2014.json from cache
Reading /home/moi/.cache/composer/repo/https---packagist.org/p-provider-2015.json from cache
Reading /home/moi/.cache/composer/repo/https---packagist.org/p-provider-2015-07.json from cache
Reading /home/moi/.cache/composer/repo/https---packagist.org/p-provider-2015-10.json from cache
Reading /home/moi/.cache/composer/repo/https---packagist.org/p-provider-2016-01.json from cache
Downloading http://packagist.org/p/provider-2016-04%24d9a3f93297214fbd9d2947094983d504bfd5c1e3ace504549d31671099615f7a.json
Writing /home/moi/.cache/composer/repo/https---packagist.org/p-provider-2016-04.json into cache
Downloading http://packagist.org/p/provider-archived%24795f9e1158fa74844fc0381151acdcf3befcbda8c98f0d8eb633e1e7e734eb8d.json
Downloading http://packagist.org/p/provider-archived%24795f9e1158fa74844fc0381151acdcf3befcbda8c98f0d8eb633e1e7e734eb8d.json
Downloading http://packagist.org/p/provider-archived%24795f9e1158fa74844fc0381151acdcf3befcbda8c98f0d8eb633e1e7e734eb8d.json

[Composer\Downloader\TransportException]
  The "http://packagist.org/p/provider-archived%24795f9e1158fa74844fc0381151acdcf3befcbda8c98f0d8eb633e1e7e734eb8d.json" file could not be downloaded: failed to open stream: HTT  
  P request failed!                                                                                                                                                                
Exception trace:
 () at phar:///home/moi/bin/composer/src/Composer/Util/RemoteFilesystem.php:458
 Composer\Util\RemoteFilesystem->get() at phar:///home/moi/bin/composer/src/Composer/Util/RemoteFilesystem.php:99
 Composer\Util\RemoteFilesystem->getContents() at phar:///home/moi/bin/composer/src/Composer/Repository/ComposerRepository.php:645
 Composer\Repository\ComposerRepository->fetchFile() at phar:///home/moi/bin/composer/src/Composer/Repository/ComposerRepository.php:558
 Composer\Repository\ComposerRepository->loadProviderListings() at phar:///home/moi/bin/composer/src/Composer/Repository/ComposerRepository.php:289
 Composer\Repository\ComposerRepository->whatProvides() at phar:///home/moi/bin/composer/src/Composer/DependencyResolver/Pool.php:204
 Composer\DependencyResolver\Pool->computeWhatProvides() at phar:///home/moi/bin/composer/src/Composer/DependencyResolver/Pool.php:193
 Composer\DependencyResolver\Pool->whatProvides() at phar:///home/moi/bin/composer/src/Composer/Package/Version/VersionSelector.php:52
 Composer\Package\Version\VersionSelector->findBestCandidate() at phar:///home/moi/bin/composer/src/Composer/Command/InitCommand.php:633
 Composer\Command\InitCommand->findBestVersionForPackage() at phar:///home/moi/bin/composer/src/Composer/Command/InitCommand.php:365
 Composer\Command\InitCommand->determineRequirements() at phar:///home/moi/bin/composer/src/Composer/Command/RequireCommand.php:108
 Composer\Command\RequireCommand->execute() at phar:///home/moi/bin/composer/vendor/symfony/console/Command/Command.php:259
 Symfony\Component\Console\Command\Command->run() at phar:///home/moi/bin/composer/vendor/symfony/console/Application.php:844
 Symfony\Component\Console\Application->doRunCommand() at phar:///home/moi/bin/composer/vendor/symfony/console/Application.php:192
 Symfony\Component\Console\Application->doRun() at phar:///home/moi/bin/composer/src/Composer/Console/Application.php:189
 Composer\Console\Application->doRun() at phar:///home/moi/bin/composer/vendor/symfony/console/Application.php:123
 Symfony\Component\Console\Application->run() at phar:///home/moi/bin/composer/src/Composer/Console/Application.php:99
 Composer\Console\Application->run() at phar:///home/moi/bin/composer/bin/composer:43
 require() at /home/moi/bin/composer:24

require [--dev] [--prefer-source] [--prefer-dist] [--no-plugins] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...

Searching for this error, I found a discussion on the subject in php.net [1]

When I run this command:

$ php -r 'file_get_contents("http://packagist.org/p/provider-archived%24795f9e1158fa74844fc0381151acdcf3befcbda8c98f0d8eb633e1e7e734eb8d.json");'

I get this output:

PHP Warning:  file_get_contents(http://packagist.org/p/provider-archived%24795f9e1158fa74844fc0381151acdcf3befcbda8c98f0d8eb633e1e7e734eb8d.json): failed to open stream: HTTP request failed!  in Command line code on line 1

Anyone who has had this problem, I recommend using CURL. How can I solve this?

Tanks!

[1] https://bugs.php.net/bug.php?id=40197

@Seldaek Seldaek added the Support label May 5, 2016
@andreich1980
Copy link

It works if you replace quotes like that

$ php -r "file_get_contents('http://packagist.org/p/provider-archived%24795f9e1158fa74844fc0381151acdcf3befcbda8c98f0d8eb633e1e7e734eb8d.json');"

But I have no idea what does it mean and how make composer download the package. Why it downloads other packages well but can't download only some of them?
My problem with http://packagist.org/p/symfony/var-dumper%24ea3512377b773427554949beddf0ed0f9a6c6f43ba6069419cde361083f78a3c.json and some other packages.

@andreich1980
Copy link

Seems that it solves the problem #5656 (comment)

@Seldaek Seldaek closed this as completed Dec 4, 2016
@pirael
Copy link

pirael commented May 8, 2018

[Composer\Downloader\TransportException]
Content-Length mismatch, received 71277 bytes out of the expected 733150
how can i solve this issue.?

@iSohail
Copy link

iSohail commented Apr 14, 2019

[Composer\Downloader\TransportException]
Content-Length mismatch, received 71277 bytes out of the expected 733150
how can i solve this issue.?

hey pirael, did you get the solution?

@frknasir
Copy link

i know this is old but, rumour has it that the issue could be caused by the redirect from http to https, so adding something like the following to composer.json might solve the issue

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

OR, alternatively, you can run composer config -g repo.packagist composer https://packagist.org before installing dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants