【问题标题】:Composer + local git repo: "could not be found in any version"Composer + 本地 git repo:“在任何版本中都找不到”
【发布时间】:2016-02-18 20:30:59
【问题描述】:

我正在使用 Composer 管理依赖项的 Symfony 项目。一些必需的包是位于特殊服务器的 git repos。我可以使用公钥访问此服务器,但我不能授予其他人访问同一服务器的权限。

现在我想让合作伙伴也参与该项目。为了让他访问包裹,包裹必须存放在更公开的位置。

为了实现这一点,我将包 repos 克隆到我自己的本地机器上并尝试使用它们。我改了composer.json

...
"require": {
    ...
    "mycompany/commons":"dev-master",
    "mycompany/data":"dev-master",
    ...
},  
...

"minimum-stability": "stable",
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "branch-alias": {
        "dev-master": "1.8-dev"
    }
},

"repositories": [
    {
        "type": "vcs",
        "url": "ssh://git@my-restricted-server.x/commons.git"
    },
    {
        "type": "vcs",
        "url": "ssh://git@my-restricted-server.x/data.git"
    },
]

改为:

"repositories": [
    {
        "type": "vcs",
        "url": "file://absolut/path/to/commons/.git"
    },
    {
        "type": "vcs",
        "url": "file://absolut/path/to/data/.git"
    },
]

当我尝试使用 composer 安装时,出现以下错误:

$ composer install --no-dev --optimize-autoloader

Loading composer repositories with package information
Installing dependencies                                          
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package mycompany/commons could not be found in any version, there may be a typo in the package name.
  Problem 2
    - The requested package mycompany/data could not be found in any version, there may be a typo in the package name.


Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

我仔细检查了包名和路径,一切都很好。知道可能出了什么问题吗?

注意:我正在尝试访问/使用我自己的本地 git 包。让我的合作伙伴访问这些包将是下一步。

【问题讨论】:

  • 我们需要查看那些私有仓库的 composer 文件。确保所有剩余的更改都已提交并在编辑之前再次测试。
  • 试试"url": "absolut/path/to/commons" 不带.gitfile://
  • @Peh 谢谢! .git 是必需的,但删除 file:// 就行了。
  • 写了一个答案来结束这个问题

标签: git symfony composer-php


【解决方案1】:

url 中删除file://

"repositories": [
    {
        "type": "vcs",
        "url": "absolut/path/to/commons/.git"
    },
    {
        "type": "vcs",
        "url": "absolut/path/to/data/.git"
    },
]

【讨论】:

    猜你喜欢
    • 2022-01-08
    • 2018-11-12
    • 2016-04-18
    • 2022-01-26
    • 2017-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多