0

I have created a package with some annotated tags for versioning (1.0.0, 1.0.1, 1.1.0 and 2.0.0). This package lives on own hosting (so not via Packagist) When trying to require the package, composer only finds the 2.0.0 version and fails on any other version requirement.

Composer.php file of project using package

{
    "name": "projectname",
    "description": "Description.",
    "keywords": ["keys"],
    "license": "Licence",
    "type": "project",
    "require": {
        ...
        "space/package-name": "~1.0" // Also tried 1.0.0, 1.0.*, ~1.0@dev - only 2.0.0 works
    }
    "repositories": [
        ...
        {
            "type": "git",
            "url": "git@gitlab.com:space/package-name.git" // Make sure package is found on specific hosting
        }
    ],
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }

On running composer show "space/package-name" I get versions: * 2.0.0. So upon update, composer produces the following error:

The requested package space/package-name ~1.0 exists as name/package-
name[2.0.0, dev-master] but these are rejected by your constraint.

It looks like composer is no able to find any other version than the latest, any way of fixing this?

Things already checked:

  • The package does not contain a version in the composer.json (that might conflict with the git tag)
  • Used tags are annotated tags and are pushed to the repo.

Updates: Might be a Gitlab - Composer issue, see this comment.

Bert H
  • 1,087
  • 1
  • 15
  • 29

1 Answers1

0

Gitlab doesn't always provide tag info when Composer tries to read the repo.

Solution: also add version info in composer.json:

{
    "name": "package/name",
    "version": "1.0.0",
    ...
}

This will be readable by composer. Careful: Git tags must match versioning info in composer.json! (might cause errors otherwise)

Bert H
  • 1,087
  • 1
  • 15
  • 29