Search code examples
phpdoctrine-ormcomposer-php

How to resolve the Composer issue when installing dependecy conflicts with the same dependecy?


Have a composer.json file in a project:

{
  "name": "some/blog",
  "license": "proprietary",
  "type": "project",
  "require": {
    "doctrine/orm": "2.11",
    "symfony/cache": "^6.0"
  },
  "require-dev": {
    "roave/security-advisories": "dev-latest",
    "symfony/var-dumper": "^6.0"
  },
  "autoload": {
    "psr-4": {
      "App\\": "src/"
    }
  }
}

and trying to install doctrine/data-fixtures package

$ composer require --dev doctrine/data-fixtures

but got an error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - doctrine/data-fixtures 1.6.6 conflicts with doctrine/data-fixtures 1.6.6.
    - doctrine/data-fixtures 1.6.5 conflicts with doctrine/data-fixtures 1.6.5.
    - doctrine/data-fixtures 1.6.4 conflicts with doctrine/data-fixtures 1.6.4.
    - doctrine/data-fixtures 1.6.3 conflicts with doctrine/data-fixtures 1.6.3.
    - doctrine/data-fixtures 1.6.2 conflicts with doctrine/data-fixtures 1.6.2.
    - doctrine/data-fixtures 1.6.1 conflicts with doctrine/data-fixtures 1.6.1.
    - doctrine/data-fixtures 1.6.0 conflicts with doctrine/data-fixtures 1.6.0.
    - doctrine/orm is locked to version 2.11.0 and an update of this package was not requested.
    - Root composer.json requires doctrine/data-fixtures ^1.6 -> satisfiable by doctrine/data-fixtures[1.6.0, ..., 1.6.6].


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

What does it mean that the dependency in some version conflicts with the same dependency in the same version? And how to resolve such an issue?

UPD: Thanks for Niko's answer the issue have solved by installing a newer version of the doctrine/orm package. According to the doctrine/data-fixtures repo, it conflicts with doctrine/orm under 2.14 version.

But why Composer's message is doctrine/data-fixtures 1.6.6 conflicts with doctrine/data-fixtures 1.6.2.? The proper one should be doctrine/data-fixtures 1.6.6 conflicts with doctrine/orm 2.11.

Looks like it's a Composer's bug.


Solution

  • Since doctrine/data-fixtures v1.6.0 (released in Dec 2022), there's a incompability with doctrine/orm older than v2.12 (introduced in PR 393).

    You should either upgrade doctrine/orm to any more current version (keep in mind that v2.11.0 that you use is more than 18 months old!), or use an older version of doctrine/data-fixtures, like in this command:

    composer require --dev doctrine/data-fixtures:"^1.5"