CodeHealer
CodeHealer

Reputation: 431

How to correct the [Composer\Downloader\TransportException] error for composer

Good day people, I have been having this problem for days now, when I try to download dependencies for my php project using composer I get this error

c:\wamp64\www\Test>composer global require "fxp/composer-asset-plugin:^1.3.1"
Changed current directory to C:/Users/Nwachukwu Favour/AppData/Roaming/Composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Installation failed, reverting ./composer.json to its original content.


  [Composer\Downloader\TransportException]
  The "http://packagist.org/p/provider-2014%241cf88bd0ed4076dc091407477ba2a76483e8598ee5365673381262e6c1d40fcf.jso
  n" file could not be downloaded: failed to open stream: HTTP request failed!


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

I am running a windows 10 OS and am suspecting that my system cannot download from the command line. I would be very glad if someone can help me solve this problem because it is hindering my project. Thanks in advance.

Upvotes: 22

Views: 69362

Answers (14)

Mohamad Mortazavi
Mohamad Mortazavi

Reputation: 1

Windows OP users: Clear "http_proxy" variable in the "Edit the system environment variables" and check it again! Then use composer "selfupdate" or "diagnose" command to check it.

Upvotes: 0

Developer Sam
Developer Sam

Reputation: 121

If you have http_proxy environment variable, just delete it from either User variables or System variable and save yourself from all this trouble.

Upvotes: 0

بشار بكاية
بشار بكاية

Reputation: 1

This problem happened to me, and I solved it by turning off the firewall. This is one of the solutions.

Upvotes: 0

Abdulrahman
Abdulrahman

Reputation: 905

just put this in command

composer config -g repo.packagist composer https://packagist.org

Upvotes: 3

jianxin Li
jianxin Li

Reputation: 1

if you are in china like me,try this:https://developer.aliyun.com/composer github connection not stable recently.I tryed https://pkg.phpcomposer.com/ first but don't work. I tryed composer diag and composer -vvv and wait.out put show cache file is :Writing C:/Users/Administrator.000/AppData/Local/Composer/repo.so i copy cache file from my colleague,and it works first,laravel run,but composer require show 404.then i found the solution above.try composer update -lock and change the repositories url to ali's.And solved.

Upvotes: 0

Blessing
Blessing

Reputation: 51

I tried the command below and it worked.

composer config -g repo.packagist composer https://packagist.org

This is just one of the options given above.

Upvotes: 5

rpalencia
rpalencia

Reputation: 29

try with composer diagnose and after that composer update -vvv

Upvotes: 1

user10599224
user10599224

Reputation:

  1. Update or Delete your 'http_proxy' variable.
  2. Delete composer
  3. Install Composer again
  4. Restart your machine.

Your are good to go.

Upvotes: 1

Abel
Abel

Reputation: 2491

I had the same error, but it was resolved in a different way for me. I used to give sudo to composer commands because folder /home/aspire/.composer is in sudo permission. I changed it to sudo chown $USER /home/aspire/.composer.

I changed the permissions as I mentioned and I ran the code

sudo composer require symfony/orm-pack

Throws error

[Composer\Downloader\TransportException]                                      
  The "https://repo.packagist.org/packages.json" file could not be downloaded:  

Then I tried

composer require symfony/orm-pack

It works

If anyone know the exact reason, please commententer image description here

Upvotes: 0

Udochukwu Enwerem
Udochukwu Enwerem

Reputation: 2823

You could also run this command on the CLI before installing any dependencies. It forces composer to use https to download all resources:

composer config -g repo.packagist composer https://packagist.org

Upvotes: 45

Rafik Farhad
Rafik Farhad

Reputation: 1202

I just updated my composer to the latest version and this problem is solved.

Try

composer self-update

To know the current version and update details:

composer diagnose

Upvotes: 11

Milan Vugrinchev
Milan Vugrinchev

Reputation: 39

just stop your antivirus software :)

for some reason antivirus software kaspersky doesn't like composer :(

I had the same error tried everything... nothing worked.

I remembered I had issues with composer in the past while my AV was on... turned it off and composer worked like a charm :)

Upvotes: 2

Dymen1
Dymen1

Reputation: 736

The issue could be caused by the redirect from http to https. (or your firewall blocking the call)

According to this article the problem could be solved by adding the following to your composer.json:

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

Forcing composer to use https connections to Packagist

Upvotes: 16

Stanley Backlund
Stanley Backlund

Reputation: 166

I found enabling OpenSSL extension in the php.ini-development/production file fixed the problem. Its located within your PHP install

Upvotes: 3

Related Questions