SWilk
SWilk

Reputation: 3466

Why some composer packages are in conflict with themselves at the same version?

I needed a xml serializer for a legacy app runing on php5. I have tried to install symfony/[email protected], whitch should work in my env.

It seem that it is not possible:

$ composer require symfony/serializer=v3.4.47
[...]
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires symfony/serializer v3.4.47 -> satisfiable by symfony/serializer[v3.4.47].
    - symfony/serializer v3.4.47 conflicts with symfony/serializer v3.4.47.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Actually, it is not possible to install this package when platform is set to php 5, as every compatibile version conflicts with itself.

EDIT:

@Nico Haase requested comparision of composer.json before and after the changes.

Here are changed fragments of it:

{
  "name": "my/library",
  "description": "I'll omit irrelevant and/or unchanged parts",
  "config": {
    "platform": {
-      "php": "5.4.45"
+      "php": "5.6.40"
    }
  },

  "require-dev": {
    "phpunit/phpunit": "^4.8",
    "wsdl2phpgenerator/wsdl2phpgenerator": "^3.4"
  },
  "require": {
    "my/library1": "^221.0.2",
    "my/library2": "dev-master",
    "my/library3": "dev-master",
    "my/library4": "dev-master",
    "ext-soap": "*",
+    "ext-json": "*",
+    "symfony/serializer": "v3.4.47",
+    "symfony/property-access": "^3.4"
  }
}

As you can see, there were no symfony packages required before changes, so I was not expected it to be installed. But it was, as a dev-dependency of wsdl2phpgenerator and it was very old. As per composer.lock the installed version was v2.8.52.

Full update of composer packages along with PHP version bump from 5.4 (which was used when this lib was previously touched) to 5.6 we are using now allowed dependencies to be upgrade to compatible versions.

All of this would not be a problem if it was not for the weird composer conflict message:

    - symfony/serializer v3.4.47 conflicts with symfony/serializer v3.4.47.

I would expect it to be something along:

    - symfony/serializer v3.4.47 requires symfony/yaml v3.4.47
    - symfony/yaml v3.4.7 confitcs with symfony/yaml v2.8.52 

...or something similar, which would hint me in direction of updating dependencies.

Upvotes: 2

Views: 690

Answers (1)

SWilk
SWilk

Reputation: 3466

It seems that actual problem the was conflict with even older version of symfony/yaml. Those legacy apps...

I have resolved the problem by running:

$ composer update
[...]
  - Upgrading symfony/yaml (v2.8.52 => v3.4.47)

and then I could successfully require the serializer package.

To sum up, if a package is in conflict with itself in the same version, accualy it can be in conflict with its dependency which is already installed in incompatibile version.

Composer error message was not helpful, though.

Upvotes: 3

Related Questions