【问题标题】:Composer won't install private package dependenciesComposer 不会安装私有包依赖项
【发布时间】:2018-12-23 15:45:31
【问题描述】:

首先,有一些相关的帖子并不真正适合我的问题。

还有更多。

我有一个包含一些私有包的 Symfony 项目。 这些都是vcs引用的:

"repositories": [
    {
        "type": "vcs",
        "url": "git@aaaaa.git"
    },
    {
        "type": "vcs",
        "url": "git@xxxxx.git"
    },
    {
        "type": "vcs",
        "url": "git@yyyyy.git"
    }
],

这按预期工作。但是,私有包 yyyy 引用了另一个私有包(我们称之为 sub-yyyy),该私有包也被包 composer.json 文件中的 vcs 类型引用。

如果我运行 composer install 它会失败并显示以下消息:

问题 1 - yyyy 的安装请求 -> yyyy]。 - yyyy 需要 sub-yyyy ^1.0.0 -> 找不到匹配的包。

潜在原因:

私有包(子yyyy)是v1.0.0标记的,如果它在主项目的composer.json文件中就可以安装。

主项目的composer.json(需要剪掉):

{
    "name": "main/project",
    "license": "proprietary",
    "type": "project",
    "prefer-stable": true,
    "repositories": [
        {
            "type": "vcs",
            "url": "git@aaaaa.git"
        },
        {
            "type": "vcs",
            "url": "git@xxxxx.git"
        },
        {
            "type": "vcs",
            "url": "git@yyyyy.git"
        }
    ],
}

yyyy包的composer.json:

{
  "name": "yyyy",
  "type": "symfony-bundle",

  "require": {
    "sub-yyyy": "^1.0.0"
  },

  "repositories": [
    {
      "type": "vcs",
      "url": "git@sub-yyyy.git"
    }
  ],
  "minimum-stability": "dev",
}

当我安装引用sub-yyyy 的yyyy 包时,有什么想法可以解决这个问题吗?

【问题讨论】:

    标签: symfony composer-php


    【解决方案1】:

    您必须将存储库条目添加到主项目中的包sub-yyyy,因为依赖项条目是不可传递的。

    来自docs

    存储库不是递归解析的。您只能将它们添加到 你的主要composer.json。依赖关系的存储库声明' composer.jsons 被忽略。

    你的主项目composer.json 应该是这样的

    {
        "name": "main/project",
        "license": "proprietary",
        "type": "project",
        "prefer-stable": true,
        "repositories": [
            {
                "type": "vcs",
                "url": "git@aaaaa.git"
            },
            {
                "type": "vcs",
                "url": "git@xxxxx.git"
            },
            {
                "type": "vcs",
                "url": "git@yyyyy.git"
            },
            {
                "type": "vcs",
                "url": "git@sub-yyyy.git"
            }
        ]
    }
    

    【讨论】:

    • 啊,好的。认为有一个更好的解决方案。谢谢
    猜你喜欢
    • 2017-10-31
    • 2017-06-28
    • 1970-01-01
    • 2014-10-24
    • 2017-09-18
    • 2018-03-04
    • 2018-02-02
    • 1970-01-01
    • 2015-01-24
    相关资源
    最近更新 更多