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

ErrorException: Undefined index: extra (impossible to composer update) #8047

Closed
tristanbes opened this issue Mar 19, 2019 · 21 comments
Closed
Assignees
Labels

Comments

@tristanbes
Copy link

tristanbes commented Mar 19, 2019

My composer.json, running composer 1.8.4:

{
    "name": "yproximite/yprox",
    "license": "proprietary",
    "description": "yProximite CMS: yProx",
    "repositories": [
        {
            "type": "composer",
            "url": "https://repo.packagist.com/yproximite/"
        },
        {
            "packagist.org": false
        },
        {
            "type": "path",
            "url": "../packages/common"
        }
    ],
    "require": {
        "php": ">=7.2",
        "a2lix/translation-form-bundle": "^2.4.2",
        "algatux/influxdb-bundle": "^2.1",
        "algolia/algoliasearch-client-php": "^1.27",
        "aws/aws-sdk-php-symfony": "^2.0",
        "beberlei/doctrineextensions": "^1.1",
        "cocur/slugify": "^3.1",
        "cspoo/swiftmailer-mailgun-bundle": "^1.1",
        "doctrine/doctrine-migrations-bundle": "v2.0.0-alpha1",
        "doctrine/migrations": "^2.0@dev",
        "egulias/email-validator": "^2.1",
        "exercise/htmlpurifier-bundle": "^1.0",
        "friendsofsymfony/ckeditor-bundle": "^1.1",
        "friendsofsymfony/jsrouting-bundle": "^2.2",
        "friendsofsymfony/user-bundle": "^2.1",
        "google/apiclient": "^2.2",
        "guzzlehttp/guzzle": "^6.3",
        "imagine/imagine": "^0.7.1",
        "incenteev/composer-parameter-handler": "^2.1",
        "iron-io/iron_mq": "^4.0",
        "iron-io/iron_worker": "^2.0",
        "knplabs/doctrine-behaviors": "^1.5",
        "knplabs/knp-components": "^1.3",
        "knplabs/knp-menu": "^2.3",
        "knplabs/knp-menu-bundle": "^2.2",
        "knplabs/knp-paginator-bundle": "^2.8",
        "knplabs/knp-snappy-bundle": "^1.5",
        "knplabs/knp-time-bundle": "^1.8",
        "kraken-io/kraken-php": "^1.6",
        "league/csv": "^9.1",
        "league/flysystem-aws-s3-v3": "^1.0",
        "lexik/jwt-authentication-bundle": "^2.5",
        "liip/imagine-bundle": "^2.1",
        "misd/phone-number-bundle": "^1.3",
        "myclabs/deep-copy": "^1.8",
        "nao-pon/flysystem-google-drive": "^1.1",
        "nelmio/cors-bundle": "^1.5",
        "ninsuo/symfony-collection": "^2.1",
        "oneup/flysystem-bundle": "^3.0",
        "ornicar/gravatar-bundle": "^1.3",
        "overblog/graphql-bundle": "^0.11.3",
        "overblog/graphql-php-generator": "^0.7.3",
        "php-http/guzzle6-adapter": "^1.1",
        "php-http/httplug-bundle": "^1.11",
        "php-translation/symfony-bundle": "^0.8.0",
        "phpoffice/phpspreadsheet": "^1.4",
        "predis/predis": "^1.1",
        "sensio/framework-extra-bundle": "^5.2",
        "sentry/sentry-symfony": "^2.0",
        "snc/redis-bundle": "3.x-dev",
        "stof/doctrine-extensions-bundle": "^1.3",
        "storefactory/zoho-subscription-bundle": "^3.0",
        "symfony-cmf/routing-bundle": "^2.1",
        "symfony/asset": "*",
        "symfony/flex": "^1.0",
        "symfony/form": "*",
        "symfony/framework-bundle": "*",
        "symfony/lock": "*",
        "symfony/monolog-bundle": "^3.3",
        "symfony/orm-pack": "^1.0",
        "symfony/proxy-manager-bridge": "*",
        "symfony/security-bundle": "*",
        "symfony/swiftmailer-bundle": "^3.2",
        "symfony/translation": "*",
        "symfony/twig-bundle": "*",
        "symfony/validator": "*",
        "tristanbes/my-poseo-bundle": "^4.0",
        "twig/extensions": "^1.5",
        "uecode/qpush-bundle": "^3.0",
        "white-october/pagerfanta-bundle": "^1.2",
        "willdurand/js-translation-bundle": "^2.6",
        "xemlock/htmlpurifier-html5": "^0.1.7",
        "yproximite/common": "@dev",
        "yproximite/ekomi-api-bundle": "^3.0",
        "yproximite/influxdb-preset-bundle": "^2.0",
        "yproximite/performance-directe-wsdl-adapter": "^1.0",
        "yproximite/sendinblue-api": "^1.0",
        "yproximite/wanna-speak-bundle": "^4.0",
        "yproximite/yprox-api-client": "^0.10.1",
        "yproximite/yprox-api-client-bundle": "^2.1",
        "zohocrm/php-sdk": "^1.1"
    },
    "require-dev": {
        "behat-extension/doctrine-data-fixtures-extension": "^5.0",
        "behat/behat": "^3.4",
        "doctrine/doctrine-fixtures-bundle": "^3.0",
        "flow/jsonpath": "^0.4.0",
        "friends-of-behat/context-service-extension": "^1.2",
        "friends-of-behat/cross-container-extension": "^1.1",
        "friends-of-behat/symfony-extension": "^1.2",
        "friendsofphp/php-cs-fixer": "^2.12",
        "mockery/mockery": "^1.1",
        "nelmio/alice": "^3.4",
        "phpspec/phpspec": "^5.0",
        "phpstan/phpstan": "^0.10.2",
        "phpstan/phpstan-doctrine": "^0.10.0",
        "phpstan/phpstan-strict-rules": "^0.10.1",
        "phpstan/phpstan-symfony": "^0.10.0",
        "symfony/debug-pack": "^1.0",
        "symfony/dotenv": "*",
        "symfony/maker-bundle": "^1.5",
        "symfony/phpunit-bridge": "*",
        "symfony/profiler-pack": "^1.0",
        "webmozart/assert": "^1.3"
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "config": {
        "bin-dir": "bin",
        "platform": {
            "php": "7.2.4"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/",
            "Features\\": "features/bootstrap/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd",
            "security-checker security:check": "script"
        },
        "post-install-cmd": [
            "Fuz\\Symfony\\Collection\\ScriptHandler::postInstall",
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ],
        "post-update-cmd": [
            "Fuz\\Symfony\\Collection\\ScriptHandler::postUpdate",
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ]
    },
    "extra": {
        "symfony": {
            "allow-contrib": true,
            "require": "4.2.4"
        },
        "incenteev-parameters": {
            "file": "config/packages/parameters.yaml"
        }
    }
}

Output of composer diagnose:

Checking composer.json: WARNING
require.doctrine/doctrine-migrations-bundle : exact version constraints (v2.0.0-alpha1) should be avoided if the package follows semantic versioning
require.snc/redis-bundle : exact version constraints (3.x-dev) should be avoided if the package follows semantic versioning
require.symfony/asset : unbound version constraints (*) should be avoided
require.symfony/form : unbound version constraints (*) should be avoided
require.symfony/framework-bundle : unbound version constraints (*) should be avoided
require.symfony/lock : unbound version constraints (*) should be avoided
require.symfony/proxy-manager-bridge : unbound version constraints (*) should be avoided
require.symfony/security-bundle : unbound version constraints (*) should be avoided
require.symfony/translation : unbound version constraints (*) should be avoided
require.symfony/twig-bundle : unbound version constraints (*) should be avoided
require.symfony/validator : unbound version constraints (*) should be avoided
require.yproximite/common : unbound version constraints (@dev) should be avoided
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: 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.8.4
PHP version: 7.2.4 - Package overridden via config.platform (actual: 7.3.3)
PHP binary path: /usr/bin/php7.3

When I run this command:

composer update

I get the following output:

Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "4.2.4"


  [ErrorException]
  Undefined index: extra

And I expected this to happen:
Well I except a dependency update :p

I'm inside a Debian VM (Vagrant+VirtualBox). My local machine is on OSX 10.14.3

@tristanbes tristanbes changed the title Undefined index: extra ErrorException: Undefined index: extra (impossible to composer update) Mar 19, 2019
@tristanbes
Copy link
Author

Removing the packagist.com repository fixes the issue but prevents us from using packagist.com :(

        {
            "type": "composer",
            "url": "https://repo.packagist.com/yproximite/"
        },
        {
            "packagist.org": false
        },

@Seldaek Seldaek self-assigned this Mar 19, 2019
@Seldaek
Copy link
Member

Seldaek commented Mar 19, 2019

@tristanbes has a symfony fork in the Private Packagist repo causing this freakout in Flex, not a composer bug.

@Seldaek Seldaek closed this as completed Mar 19, 2019
@tristanbes
Copy link
Author

Thanks @Seldaek. Will remove all forks to prevent this kind of issues again and try to fork the packages under personal space when sending patches.

@stof
Copy link
Contributor

stof commented Mar 19, 2019

this should probably still be reported to Flex though

@ostrolucky
Copy link

We started to have same problem, but we don't use custom symfony fork, or this drupal plugin. What helped in our case was

Index: composer.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- composer.json	(revision c0719fbceabff1d1acc856412a73b8588a930fcc)
+++ composer.json	(date 1601982579444)
@@ -157,8 +157,7 @@
         "symfony-tests-dir": "tests",
         "symfony-assets-install": "relative",
         "symfony": {
-            "allow-contrib": false,
-            "require": "4.3.*"
+            "allow-contrib": false
         }
     }
 }

I would like to know what is the trigger of this problem though, since this worked fine till now.

@krewetka
Copy link

krewetka commented Oct 6, 2020

I am having the same problem today as well without custom forks

For me it happens in plugin I use - exactly in this line https://github.com/rubenrua/symfony-clean-tags-composer-plugin/blob/master/src/Cache.php#L61

so i guess it is not composer related... but still strange it started today.

I looks like some change done recently in symfony/symfony

@krewetka
Copy link

krewetka commented Oct 6, 2020

@ostrolucky I think this commit in symfony released today broke it

symfony/symfony@5f1c3a7#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780

@denisp1993
Copy link

Same problem here, a couple of days ago everything works fine, now when i try to install a Drupal module with composer i get an error.

[ErrorException]
Undefined index: extra

Exception trace: () at /usr/share/nginx/html/yoursite/vendor/zaporylie/composer-drupal-optimizations/src/Cache.php:76 Composer\Util\ErrorHandler::handle() at /usr/share/nginx/html/yoursite/vendor/zaporylie/composer-drupal-optimizations/src/Cache.php:76 zaporylie\ComposerDrupalOptimizations\Cache->removeLegacyTags() at /usr/share/nginx/html/yoursite/vendor/zaporylie/composer-drupal-optimizations/src/TruncatedComposerRepository.php:21 zaporylie\ComposerDrupalOptimizations\TruncatedComposerRepository->fetchFile() at phar:///usr/local/bin/composer/src/Composer/Repository/ComposerRepository.php:366 Composer\Repository\ComposerRepository->whatProvides() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Pool.php:213 Composer\DependencyResolver\Pool->computeWhatProvides() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Pool.php:202 Composer\DependencyResolver\Pool->whatProvides() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php:173 Composer\DependencyResolver\RuleSetGenerator->whitelistFromPackage() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php:153 Composer\DependencyResolver\RuleSetGenerator->allowListFromPackage() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php:371 Composer\DependencyResolver\RuleSetGenerator->getRulesFor() at phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php:217 Composer\DependencyResolver\Solver->solve() at phar:///usr/local/bin/composer/src/Composer/Installer.php:489 Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:232 Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:163 Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Command/Command.php:245 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:835 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:185 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:281 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:117 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:113 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:61 require() at /usr/local/bin/composer:24

@krewetka
Copy link

krewetka commented Oct 6, 2020

@denisp1993

there is discussion about it on drupal zaporylie/composer-drupal-optimizations#22

still it is not composer/compser fault so not topic for this repo :)

@stof
Copy link
Contributor

stof commented Oct 6, 2020

the issue is that composer-drupal-optimizations assumes that a master branch always has a branch-alias, while there is no such guarantee in composer. And when symfony removed the branch-alias, drupal projects using that plugin became affected by the wrong assumption.

@krewetka
Copy link

krewetka commented Oct 6, 2020

Yes, drupal and also symfony-clean-tags-composer-plugin which was my case today.

@DavidGarciaCat
Copy link

Funny thing, this error just started to happen today to me, and it fails when using composer 1.x but upgrading to composer 2.x solves the problem.

@LicenceOne
Copy link

LicenceOne commented Oct 7, 2020

Error started to happen today for me too.

Since i'm not using the drupal plugin neither symfony-clean-tags-composer-plugin and i'd like to avoid jumping on the 2.x version of composer what can i do to solve that Undefined index: extra situation ?

Tried the @ostrolucky change but no success :/

@stof
Copy link
Contributor

stof commented Oct 7, 2020

@Skape252 please check at the stack trace of your exception to identify which place in your project is wrongly assuming that a dev-master alias exists (which is absolutely not a guarantee in Composer)

@shahidnafridi
Copy link

shahidnafridi commented Oct 7, 2020

@Skape252
You could change this line in vendor/symfony/flex/src/Cache.php as in screenshot temporarily

from
https://files.slack.com/files-pri/T38L468JV-F01C4754L1G/image.png
image

to
image

After that composer update should work. After package update, it should solve the problem and you don't need to change this line again.

@stof
Copy link
Contributor

stof commented Oct 7, 2020

@shahidnafridi your patch still does not account for missing branch-alias, if there are other extra field

@LicenceOne
Copy link

No other extra field for me so @shahidnafridi solution works fine, thanks

@stevenlafl
Copy link

stevenlafl commented Oct 7, 2020

If your problem is with Drupal, a quick solution is to edit composer.lock to update zaporylie/composer-drupal-optimizations. the relevant sections below are version and reference to update.

            "name": "zaporylie/composer-drupal-optimizations",
            "version": "1.1.2",

and

            "source": {
                "type": "git",
                "url": "https://github.com/zaporylie/composer-drupal-optimizations.git",
                "reference": "0d6ebd8bc03679d312f99a1e4e950685dbf0ff18"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/zaporylie/composer-drupal-optimizations/zipball/0d6ebd8bc03679d312f99a1e4e950685dbf0ff18",
                "reference": "0d6ebd8bc03679d312f99a1e4e950685dbf0ff18",
                "shasum": ""
            },

then run composer install and composer update --lock

Or, you know, rm -rf vendor/zaporylie/composer-drupal-optimizations && composer update zaporylie/composer-drupal-optimizations is also quick.

@DavidGarciaCat
Copy link

I understand that upgrading to Composer 2.0 RC1 might not be easy (or acceptable in some cases), and I always advise caution on such kind of actions, especially when a serious app or environment is involved.

However, I can say that Composer 2 has given me successful results so far (for the vague test that I have done on small projects), and I don't see a reason not to use it if it solves the problem.

Anyway, I still find concerning that yesterday everything was working and today started to fail after getting the latest version of Composer 1 (when booting up my Docker containers) but works with Composer 2.

@ostrolucky
Copy link

Issue is using old symfony/flex version. All that updating composer to 2.0 does is that you are forced to update symfony/flex version with it. Also, tricky part is updating symfony/flex while it crashes because you have old version.

@krewetka
Copy link

krewetka commented Oct 7, 2020

@DavidGarciaCat it is not composer issue. It is change in symfony/symfony and some other symfony libraries which was done yesterday and broke some other libraries/vendors like older versions of flex (but not only).

For me it happened without any update of conposer itself.

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

10 participants