Chris Brown
Chris Brown

Reputation: 4635

Installing or updating symfony/flex via Composer silently fails

I have a project using symfony/flex in which I cannot run composer install or composer update. I also can't create a new composer project with symfony/flex as a dependency as the failure is the same. For example;

mkdir foo && cd foo && composer require symfony/flex -vvv

Always has the following output;

...
Package operations: 1 install, 0 updates, 0 removals
Installs: symfony/flex:v1.2.6
  - Installing symfony/flex (v1.2.6): Reading /Users/me/.composer/cache/files/symfony/flex/17b622276922e6347ea129acd6238ae1c41d96b6.zip from cache
Loading from cache
 Extracting archiveExecuting command (CWD): unzip -qq  '/Users/me/projects/foo/vendor/symfony/flex/2064a553f7cdf064ba8c1b62c7087ec6' -d '/Users/me/projects/foo/vendor/composer/65215880'
Loading plugin Symfony\Flex\Flex
Downloading https://flex.symfony.com/versions.json

The download hangs for a few seconds at the point of downloading versions.json before silently failing. vendor/symfony/flex exists.

What could be the cause of this failure? My colleague can run the same command successfully so I'm assuming an issue with my local composer. I have attempted reinstall composer and clearing the cache with no success.

Edit: now when running composer update -vvv in an existing project I get the following output

...
Downloading https://repo.packagist.org/packages.json

Where it also hangs, so it looks like composer cannot download certain JSON files? Packages download fine so it doesn't look like a lack of internet.

Edit 2: I can also confirm using composer update --no-plugins does work within the existing project.

Upvotes: 7

Views: 22859

Answers (6)

Marcos Labad
Marcos Labad

Reputation: 1191

Solved it by removing vendor and var/cache directories. Then performing a composer install.

Upvotes: 0

An Capone
An Capone

Reputation: 131

Since my experience is with the same issue and thus not deserving of a standalone Q&A, I'll just post it as an answer to this, as the core problem is exactly the same, Symfony flex servers being shut down.

In my dockered project, dependencies were not being installed during build and after some investigation I found out, that composer install would always fail due to being unable to reach the Symfony flex server. It looked like a DNS problem at first, but it ended up being a problem with Symfony flex servers being shut down and an old version (1.3) of "symfony/flex" in composer.json.

I did pretty much everything in the most upvoted answer, but

$ composer update symfony/flex --no-plugins --no-scripts

returned an error due to a dependency of the symfony/flex package hitting the API limit. However as suggested I created a Personal access token and everything went smoothly from there.

Upvotes: 1

Alessandro Lai
Alessandro Lai

Reputation: 2274

Old Flex infrastructure is being shut down, you need to update Flex to AT LEAST 1.17.1: symfony.com/blog/upgrade-flex-on-your-symfony-projects

To do that, you need to run:

composer update symfony/flex --no-plugins --no-scripts

Upvotes: 7

belem
belem

Reputation: 399

Run this, solved my issue

> composer update symfony/flex --no-plugins --no-scripts

then keep this config in my composer.json

  {
    "require": {
        "symfony/flex": "^1.1",
     },
     "conflict": {
         "symfony/symfony": "*"
     }
  }

Upvotes: 2

Terry Visser
Terry Visser

Reputation: 3

I had the same problem.

I added cloudflare dns 1.1.1.1 to my dns.

This solved it for me

Upvotes: -3

weegee
weegee

Reputation: 3409

When composer isn't working as expected, you should reset it and update it like this. First

$ composer clearcache

Then update

$ composer self-update

Then run a diagnostic

$ composer diagnose

Then cd to where you have composer.json located and do

$ composer dump-autoload

Then

$ composer install

Should fix this issue. Another approach includes

$ composer update symfony/flex --no-plugins --no-scripts

Also, this can arise due to a conflict between symfony/flex and symfony/symfony. To remove that conflict follow these steps

$ composer remove symfony/symfony

then edit your composer.json file like

{
    "require": {
        "symfony/flex": "^1.0",
     },
     "conflict": {
         "symfony/symfony": "*"
    }
}

Upvotes: 19

Related Questions