如何解决Composer安装依赖项与相同依赖项冲突的问题?

huangapple go评论64阅读模式
英文:

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

问题

在项目中有一个 composer.json 文件:

{
  "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/"
    }
  }
}

并尝试安装 doctrine/data-fixtures 包:

$ composer require --dev doctrine/data-fixtures

但是遇到了错误:

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.

这是什么意思,某个版本的依赖项与相同版本的相同依赖项冲突?如何解决这个问题?

更新:感谢Niko的回答,问题已通过安装较新版本的 doctrine/orm 包解决。根据 doctrine/data-fixtures 存储库,它与 doctrine/orm 低于2.14版本 冲突。

但为什么Composer的消息是 doctrine/data-fixtures 1.6.6 conflicts with doctrine/data-fixtures 1.6.2.?正确的消息应该是 doctrine/data-fixtures 1.6.6 conflicts with doctrine/orm 2.11

看起来这是Composer的一个 bug。

英文:

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.

答案1

得分: 1

自从doctrine/data-fixtures v1.6.0(于2022年12月发布)以来,与早于v2.12的doctrine/orm存在不兼容性(在PR 393中介绍)。

您应该要么升级doctrine/orm到任何更新的版本(请记住,您使用的v2.11.0已经超过18个月了!),要么使用旧版本的doctrine/data-fixtures,就像在这个命令中一样:

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

英文:

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"

huangapple
  • 本文由 发表于 2023年7月12日 23:07:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76672050.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定