Composer shows conflict between 2 compatible packages (original)

天涯浪子 提交于 2019-12-20 07:50:45

问题


I have an error trying to composer install my dependencies. Same error with composer update.

It says there's a conflict between symfony/web-server-bundle 4.3.3 and symfony 3.4 but those packages are supposed to be compatible:

  • https://github.com/symfony/web-server-bundle/blob/4.3/composer.json
  • https://packagist.org/packages/symfony/web-server-bundle

Here is my console output:

$ composer install --ignore-platform-reqs
Deprecation warning: Your package name theredled/. is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9]([_.-]?[a-z0-9]+)*". Make sure you fix this as Composer 2.0 will error.
Deprecation warning: require.beberlei/DoctrineExtensions is invalid, it should not contain uppercase characters. Please use beberlei/doctrineextensions instead. Make sure you fix this as Composer 2.0 will error.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for symfony/symfony v3.4.30 -> satisfiable by symfony/symfony[v3.4.30].
    - don't install symfony/web-server-bundle v4.3.3|don't install symfony/symfony v3.4.30
    - Installation request for symfony/web-server-bundle v4.3.3 -> satisfiable by symfony/web-server-bundle[v4.3.3].

Here is my composer.json:

{
    "name": "theredled/.",
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-4": {
            "": "src/"
        },
        "classmap": [
            "app/AppKernel.php",
            "app/AppCache.php"
        ]
    },
    "autoload-dev": {
          "psr-4": {
              "App\\Tests\\": "tests/"
          }
      },
    "require": {
        "php": ">=7.1.0",
        "symfony/symfony": "3.4.*",
        "doctrine/orm": "~2.6",
        "doctrine/doctrine-bundle": "~1.9",
        "symfony/swiftmailer-bundle": "~3.2",
        "symfony/monolog-bundle": "~3.3",
        "sensio/distribution-bundle": "~5.0",
        "incenteev/composer-parameter-handler": "~2.1",
        "twig/extensions": "^1.5",
        "liip/imagine-bundle": "^2.1",
        "spe/filesize-extension-bundle": "~1.0.0",
        "doctrine/doctrine-migrations-bundle": "^1.3",
        "beberlei/DoctrineExtensions": "^1.1",
        "excelwebzone/recaptcha-bundle": "^1.5",
        "knplabs/knp-snappy-bundle": "^1.5",
        "knplabs/knp-paginator-bundle": "^2.8",
        "debesha/doctrine-hydration-profiler-bundle": "^1.3",
        "xmon/color-picker-type-bundle": "^1.0",
        "symfony/assetic-bundle": "^2.8",
        "symfony/console": "~3.4",
        "eightpoints/guzzle-bundle": "^7.4",
        "symfony/webpack-encore-bundle": "^1.6",
        "sentry/sentry-symfony": "^2.1",
        "cocur/slugify": "^3.2"
    },
    "require-dev": {
        "sensio/generator-bundle": "~3.0",
        "symfony/browser-kit": "^4.3",
        "symfony/css-selector": "^4.3",
        "symfony/phpunit-bridge": "^4.3",
        "onurb/doctrine-yuml-bundle": "1.1.5",
        "phpunit/php-code-coverage": "^6.1",
        "hautelook/alice-bundle": "^2.5",
        "doctrine/data-fixtures": "^1.3",
        "symfony/web-server-bundle": "^4.3"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ]
    },
    "config": {
        "bin-dir": "bin",
        "platform": {
            "php": "7.1.11"
        }
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "symfony": {
            "allow-contrib": "true"
        }
    }
}

Any idea?


回答1:


As I described it in another answer recently, you do get this error message because symfony/symfony acts as a replacement of symfony/web-server-bundle at its exact same version, because of this line: https://github.com/symfony/symfony/blob/3.4/composer.json#L85

The composer documentation tells you exactly that and takes Symfony as an example to explain the replace section:

This is also useful for packages that contain sub-packages, for example the main symfony/symfony package contains all the Symfony Components which are also available as individual packages. If you require the main package it will automatically fulfill any requirement of one of the individual components, since it replaces them.

Source: https://getcomposer.org/doc/04-schema.md#replace

So with your composer.json as it stands, you are instructing composer to install symfony/web-server-bundle at the version 4.3.3 and to install symfony/web-server-bundle at the version 3.4.30 (via the request to install symfony/symfony at version 3.4.30, that says it replace that package), and composer end up in an incompatible state, as explained by the error, to install a package at two different version at the same time.

- don't install symfony/web-server-bundle v4.3.3|don't install symfony/symfony v3.4.30
- Installation request for symfony/web-server-bundle v4.3.3 -> satisfiable by symfony/web-server-bundle[v4.3.3].

=> don't install symfony/web-server-bundle is really what it means: you actually don't need it, it is part of symfony/symfony already

From here you have three options:

  1. You remove the requirement for symfony/web-server-bundle in your composer.json (but that means you will have to live with that package at the version 3.4.30, as provided by symfony/symfony)
  2. You upgrade your symfony/symfony package to 4.3.3 (still leaving the requirement of symfony/web-server-bundle out of your composer.json because symfony/symfony does replace it).
  3. You require the symfony/* package that you need one by one, but not via the "super-package" symfony/symfony.
    That's more work and more possible incompatibilities to deal with in a long term, but that is the only way to have symfony/web-server-bundle at version ^4.0 when still having other Symfony packages in versions ^3.0.
    An example of that would be to replace this line of your composer.json:

    "symfony/symfony": "3.4.*",
    

    with

    "symfony/asset": "3.4.*",
    "symfony/browser-kit": "3.4.*",
    "symfony/cache": "3.4.*",
    "symfony/class-loader": "3.4.*",
    "symfony/config": "3.4.*",
    "symfony/console": "3.4.*",
    "symfony/css-selector": "3.4.*",
    "symfony/dependency-injection": "3.4.*",
    "symfony/debug": "3.4.*",
    "symfony/debug-bundle": "3.4.*",
    "symfony/doctrine-bridge": "3.4.*",
    "symfony/dom-crawler": "3.4.*",
    "symfony/dotenv": "3.4.*",
    "symfony/event-dispatcher": "3.4.*",
    "symfony/expression-language": "3.4.*",
    "symfony/filesystem": "3.4.*",
    "symfony/finder": "3.4.*",
    "symfony/form": "3.4.*",
    "symfony/framework-bundle": "3.4.*",
    "symfony/http-foundation": "3.4.*",
    "symfony/http-kernel": "3.4.*",
    "symfony/inflector": "3.4.*",
    "symfony/intl": "3.4.*",
    "symfony/ldap": "3.4.*",
    "symfony/lock": "3.4.*",
    "symfony/monolog-bridge": "3.4.*",
    "symfony/options-resolver": "3.4.*",
    "symfony/process": "3.4.*",
    "symfony/property-access": "3.4.*",
    "symfony/property-info": "3.4.*",
    "symfony/proxy-manager-bridge": "3.4.*",
    "symfony/routing": "3.4.*",
    "symfony/security": "3.4.*",
    "symfony/security-core": "3.4.*",
    "symfony/security-csrf": "3.4.*",
    "symfony/security-guard": "3.4.*",
    "symfony/security-http": "3.4.*",
    "symfony/security-bundle": "3.4.*",
    "symfony/serializer": "3.4.*",
    "symfony/stopwatch": "3.4.*",
    "symfony/templating": "3.4.*",
    "symfony/translation": "3.4.*",
    "symfony/twig-bridge": "3.4.*",
    "symfony/twig-bundle": "3.4.*",
    "symfony/validator": "3.4.*",
    "symfony/var-dumper": "3.4.*",
    "symfony/web-link": "3.4.*",
    "symfony/web-profiler-bundle": "3.4.*",
    "symfony/workflow": "3.4.*",
    "symfony/yaml": "3.4.*"
    

    Which I just created by copying the replace section of symfony/symfony's composer.json, where I replaced the "self.version" by your actual symfony/symfony version, and finally, removed the package symfony/web-server-bundle, since you require it on another version already.

As for your misunderstanding of the composer.json of symfony/web-server-bundler, this package is indeed compatibe with the packages of Symfony at version ^4.0 that are listed:

  • symfony/config
  • symfony/console
  • symfony/dependency-injection
  • symfony/http-kernel
  • symfony/polyfill-ctype
  • symfony/process

But not with the bundled "super-package" symfony/symfony that is indeed not present in the require section of its composer.json



来源:https://stackoverflow.com/questions/57589779/composer-shows-conflict-between-2-compatible-packages-original

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!