4lxndr
4lxndr

Reputation: 317

Composer fails for private Gitlab Repository

i have a new project where i want to require a private Gitlab Repository. Both Repositories belong to me, so i can change whatever i want.

The composer.json of the project looks like:

{
    "name": "thisismyproject",
    "type": "project",
    "minimum-stability": "dev",
    "authors": [
        {
            "name": "me",
            "email": "[email protected]"
        }
    ],
    "repositories": [
        {
            "type": "vcs",
            "url": "https://gitlab.com/me/my-wordpress-plugin.git"
        }
    ],
    "require": {
        "composer/installers": "^1.0@dev",
        "me/my-wordpress-plugin": "dev-master"
    },
    "extra": {
        "installer-paths": {
            "wp-content/plugins/{$name}": [
                "type:wordpress-plugin"
            ]
        }
    },
    "config": {
        "gitlab-token" : {
            "gitlab.com": "thisismysupersecrettoken"
        }
    }
}

The composer.json of the wordpress plugin repository looks like:

{
    "name": "WordPress Plugin",
    "description": "lorem",
    "type": "wordpress-plugin",
    "authors": [
        {
            "name": "me",
            "email": "[email protected]"
        }
    ],
    "require": {},
    "autoload": {
        "psr-4": {
            "SomeNamespace\\": "."
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "1.0-dev"
        }
    }
}

The output of composer update -vvv looks like:

Downloading https://gitlab.com/api/v4/projects/me%2Fmy-wordpress-plugin
Downloading https://gitlab.com/api/v4/projects/me%2Fmy-wordpress-plugin/repository/branches?per_page=100
Downloading https://gitlab.com/api/v4/projects/me%2Fmy-wordpress-plugin/repository/files/composer%2Ejson/raw?ref=14
3c1818bfc96dcaa4ee5c26cc0bd379c395491c
Downloading https://gitlab.com/api/v4/projects/me%2Fmy-wordpress-plugin/repository/tags?per_page=100
Reading composer.json of WordPress Plugin (v1.0.0)
Downloading https://gitlab.com/api/v4/projects/me%2Fmy-wordpress-plugin/repository/files/composer%2Ejson/raw?ref=14
3c1818bfc96dcaa4ee5c26cc0bd379c395491c
Writing /home/vagrant/.cache/composer/repo/gitlab.com/me/my-wordpress-plugin/143c1818bfc96dcaa4ee5c26cc0bd379c39549
1c into cache
Importing tag v1.0.0 (1.0.0.0)
Reading composer.json of WordPress Plugin (master)
Importing branch master (dev-master)
Downloading https://packagist.org/packages.json
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package me/my-wordpress-plugin could not be found in any version, there may be a typo in the pa
ckage 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  for more details.

Read  for further common problems.

Any advice?

Thanks.

Upvotes: 3

Views: 3021

Answers (1)

Chin Leung
Chin Leung

Reputation: 14921

You are receiving the error because your package name is not the same.

To fix it, you need to update the name in the composer.json of your WordPress plugin.

{
    "name": "me/my-wordpress-plugin",
    "description": "WordPress Plugin",
    "type": "wordpress-plugin",
    "authors": [
        {
            "name": "me",
            "email": "[email protected]"
        }
    ],
    "require": {},
    "autoload": {
        "psr-4": {
            "SomeNamespace\\": "."
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "1.0-dev"
        }
    }
}

The name should match the key in the require of your main composer.json:

"require": {
    "composer/installers": "^1.0@dev",
    "me/my-wordpress-plugin": "dev-master"
},

Upvotes: 4

Related Questions