简体   繁体   中英

Unable to composer install/require from a private GitLab repo (namespace)

I am having problems installing a private composer library from a private GitLab repo.

My private library which I want to use has this in it's composer.json and is stored on my GitLab:

{
    "name": "zlatan/app-client",
    "type": "library",
    "license": "MIT",
    "description": "Client in PHP",
    "authors": [
        {
            "name": "Zlatan Omerovic",
            "email": "gmail@com.zlatan"
        }
    ],
    "require": {
        "symfony/http-client": "^4.3"
    },
    "autoload": {
        "psr-4": {
            "AppClient\\": "src/"
        }
    }
}

My Git path to my library is: /namespace/project/app-client.git , ie

git@zlatan.gitlab.com:namespace/project/app-client.git

And now I'd like to use that library which I have named zlatan/app-client , in another composer.json file:

{
    "name": "zlatan/composer",
    "authors": [
        {
            "name": "Zlatan Omerovic",
            "email": "gmail@com.zlatan"
        }
    ],
    "require": {
        "zlatan/app-client": "master"
    },
    "repositories": [
        {
            "type": "git",
            "url": "git@zlatan.gitlab.com:namespace/project/app-client.git"
        }
    ]
}

Now, when I run composer install , I always get this output:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package zlatan/app-client 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://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

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

My first and only guess is that these GitLab namespaces / prefixes in the URI are making a problem?

Is it possible to resolve this?

Try using dev-master to reference to your master branch.

Using master will instruct Composer to search for a tag named master and if that does not exist, it will fail.

Additionally, you can try adding "minimum-stability": "dev" to your composer.json to make sure development versions of packages can be installed.

Try to use proxy or vpn app when you want to use composer install command

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM