Sanket Hande
Sanket Hande

Reputation: 43

Getting "Could not find a version of package .." in composer inspite of having tags in Github branch of package

I am learning on how to upload a package on packagist.org. I created a github repository for testing with composer.json file - https://github.com/perials/check and a composer package using this github repository - https://packagist.org/packages/perials/check

When I try to install this package using composer require perials/check I get below error

[InvalidArgumentException]                                              
Could not find a version of package perials/check matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability.

From what I read in other related questions on SO this error occurs if there are no stable releases of github branch. But thing is that I already have some releases.

I also tried composer require perials/check:dev-master and composer require perials/check:7.1.0 but then I get below error

[InvalidArgumentException]             
Could not find package perials/check.  

Did you mean this?                     
perials/check

Upvotes: 4

Views: 14201

Answers (3)

Jonnathas Luiz
Jonnathas Luiz

Reputation: 11

I am also learning how to create packages and have the same problem, but in my case I created a v1.0.0 tag for my package and that solves the problem.

Upvotes: 1

Enrique René
Enrique René

Reputation: 598

You can accept no stable version packages. See composer in docs (https://getcomposer.org/doc/04-schema.md#package-links).

Paste piece here for convinience:

You can apply them to a constraint, or apply them to an empty constraint if you want to allow unstable packages of a dependency for example.

composer.json:

{
    "require": {
        "monolog/monolog": "1.0.*@beta",
        "acme/foo": "@dev"
    }
}

In your case you would do:

{
    "require": {
        "perials/check": "7.1.0@dev"
    }
}

and then run rm composer.lock; composer install.

Upvotes: 0

Md Abu Ahsan Basir
Md Abu Ahsan Basir

Reputation: 530

It was an issue with Singapore mirror for the packagist metadata. Now it should be resolved. https://github.com/composer/composer/issues/8347#issuecomment-537176755

If still not solve your issue please add "minimum-stability": "dev" in your composer.json

{
    "name": "perials/check",
    "description": "Package for testing packagist",
    "license": "MIT",
    "authors": [
        {
            "name": "Perials",
            "email": "[email protected]"
        }
    ],
    "autoload": {
        "psr-4": {"Abc\\": "src/xyz"}
    },
    "require": {},
    "minimum-stability": "dev"
}

Upvotes: 11

Related Questions