【问题标题】:Composer failed to clone git repoComposer 无法克隆 git repo
【发布时间】:2020-10-06 16:22:58
【问题描述】:

我正在尝试在我的私人 GitLab 存储库中获取模块的开发版本。

使用我在other answers 中找到的内容,我项目的composer.json 是:

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://git.amh.net.au"
        },
        {
            "type": "package",
            "package": {
                "name": "amh-framework/amh-framework",
                "version": "dev-develop",
                "type": "package",
                "source": {
                    "url": "git.amh.net.au:/var/opt/gitlab/git-data/repositories/amh-framework/amh-framework.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    ],

    "require": {
        "amh-framework/amh-framework": "dev-develop",
    }
}

但是当我运行composer update 时,它会抛出一个RuntimeException:

Failed to execute git clone --no-checkout '' '/var/checkouts/reports/reporter/vendor/amh-framework/amh-framework' && cd '/var/checkouts/reports/reporter/vendor/amh-framework/amh-framework' && git remote add composer '' && git fetch composer                                                                                                                                                                                                                                                

fatal: repository '' does not exist

composer update -vvv 的输出是:

Resolving dependencies through SAT
Dependency resolution completed in 0.001 seconds
  - Installing amh-framework/amh-framework (dev-develop 4d135f4)
Executing command (CWD): git --version
    Cloning 4d135f4b01dc896ffc722d8e24cc106d38cb4602
Executing command (CWD): git clone --no-checkout '' '/var/checkouts/reports/reporter/vendor/amh-framework/amh-framework' && cd '/var/checkouts/reports/reporter/vendor/amh-framework/amh-framework' && git remote add composer '' && git fetch composer
Executing command (CWD): git --version
Failed: [RuntimeException] Failed to execute git clone --no-checkout '' '/var/checkouts/reports/reporter/vendor/amh-framework/amh-framework' && cd '/var/checkouts/reports/reporter/vendor/amh-framework/amh-framework' && git remote add composer '' && git fetch composer

fatal: repository '' does not exist

因此,它似乎确实会检查存储库以获取最新的提交 (4d135f4b01dc896ffc722d8e24cc106d38cb4602) - 但在克隆时失败了。

我可以手动克隆项目,所以它似乎没有权限:

git clone git.amh.net.au:/var/opt/gitlab/git-data/repositories/amh-framework/amh-framework.git

我能做些什么来解决这个问题?

【问题讨论】:

  • 是你完整的 composer.json 文件还是你遗漏了什么?因为将其验证为 json 文件会给我两个错误。
  • 现在我已经完全封闭了对象,效果会更好吗?
  • 是的,它在删除第 17 行末尾的尾随逗号后确实如此。那么,为什么它对您不起作用?
  • 早知道就不会在这里问了

标签: git composer-php


【解决方案1】:

根据composer's documentation,您只需要:

{
    "require": {
        "amh-framework/amh-framework": "dev-develop"
    },
    "repositories": [ 
        {
            "type": "vcs",
            "url": "git@git.amh.net.au:/var/opt/gitlab/git-data/repositories/amh-framework/amh-framework.git"
        }
     ]
}

确保对版本使用实际的分支。

【讨论】:

  • 我仍然收到错误 - 这是我最初尝试的。在这里阅读其他人的问题后,我得出了当前的尝试。
【解决方案2】:
git clone ''
fatal: repository '' does not exist

似乎在上面的示例中,Composer 正在尝试克隆一个不存在的存储库。

git clone --no-checkout ---> ''

所以也许在你的 composer.json 文件中的某个地方你的 url 是空的。

另外,我在上面的 composer.json 文件中发现了至少两个问题。

错误:第 1 行的解析错误:“repositories”:[{“type”:“packa --------------^ 期待 'EOF'、'}'、','、']',得到 ':'

错误:第 17 行的解析错误:...k": "dev-develop", }} ----------------------^ 期待 'STRING',得到 '}'

【讨论】:

    【解决方案3】:

    问题是由于存储库的排序 - 我们使用 satis to 作为私有包服务器。出于某种原因,satis 说 dev-master 分支可用,但不能正确提供它(不过它适用于标签)。

    通过更改文件使 git repo 列在 satis 之前,它可以工作:

    {
        "repositories": [
            {
                "type": "vcs",
                "url": "git@git.amh.net.au:amh-framework/amh-test.git"
            },
            {
                "type": "composer",
                "url": "https://svn.amh.net.au:8002"
            }
        ],
        "require": {
            "amh-framework/amh-test": "dev-master"
        }
    }
    

    【讨论】:

      【解决方案4】:

      在我的情况下,这是因为我错过了 git 的 auth.json 凭据,以便能够获取存储库,因为它们是私有的。

      喜欢:

      {
        "github-oauth": {
          "github.com": "personal-access-key"
        }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-10-08
        • 2010-11-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多