Search code examples
gitcomposer-php

Composer failed to clone git repo


I'm trying to get a development version of a module in my private GitLab repository.

Using what I've found in other answers, my project's composer.json is:

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

But when I run composer update, it throws a 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

The output from composer update -vvv is:

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

So, it does seem to check the repo to get the latest commit (4d135f4b01dc896ffc722d8e24cc106d38cb4602) - but it's failing when cloning.

I can manually clone the project, so it doesn't appear to be permissions:

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

What can I do to fix this?


Solution

  • The problem is due to ordering of repositories - we're using satis to as a private package server. For some reason, satis says that the dev-master branch is available, but wouldn't correctly provide it (it works for tags, though).

    By changing the file so that the git repo is listed ahead of satis, it works:

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