Composer 找不到本地 vcs 依赖项

2022-01-21 00:00:00 php composer-php

我有一个项目依赖于一个本地包,它本身依赖于另一个本地包.

项目

<前>{...存储库":[{包装师":假},{类型":vcs","url": "/path/to/local/package1"},],要求": {本地/package1":开发主机"}...}

套餐一

<前>{...存储库":[{包装师":假},{类型":vcs","url": "/path/to/local/package2"},],要求": {本地/package2":开发大师"}...}

当我在 package1 上执行 composer install 时,一切正常,packages2 被找到并安装.但是当我在 project 上执行此操作时,它找不到 package2 并出现此错误:

<上一页>问题 1- local/package1 dev-master 的安装请求 -> local/package1[dev-master] 可满足.- local/package1 dev-master 需要 local/package2 dev-master -> 找不到匹配的包.

解决方案

来自 Composer 手册:

<块引用>

存储库仅适用于根包和您的依赖项中定义的存储库将不会被加载.如果需要,请阅读 常见问题解答条目了解原因.

I have a project that depends on a local package which in itself depends on another local pakcage.

Project

{
...
  "repositories": [
    {
      "packagist": false
    },
    {
      "type": "vcs",
      "url": "/path/to/local/package1"
    },
  ],  
  "require": {
    "local/package1": "dev-master"
  }
...
}

Package 1

{
...
  "repositories": [
    {
      "packagist": false
    },
    {
      "type": "vcs",
      "url": "/path/to/local/package2"
    },
  ],  
  "require": {
    "local/package2": "dev-master"
  }
...
}

When I do a composer install on package1, everything works as expected, packages2 is found and is installed. But when I do it on project it cannot find package2 with this error:

 Problem 1
    - Installation request for local/package1 dev-master -> satisfiable by local/package1[dev-master].
    - local/package1 dev-master requires local/package2 dev-master -> no matching package found.

解决方案

From Composer manual:

Repositories are only available to the root package and the repositories defined in your dependencies will not be loaded. Read the FAQ entry if you want to learn why.

相关文章