Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer throws error "Could not find package with stability stable."

I have tried to publish a project with composer. The project resides at github, and are published through packagist.org.

But when I try to create my project with composer it fails with this error message:

"Could not find package madskullcreations/simplicity with stability stable."

I use the following command:

composer create-project madskullcreations/simplicity

The composer.json contains this:

{
    "name": "madskullcreations/simplicity",
    "description": "Website made simple!",
    "homepage": "https://madskullcreations.com",
    "type": "project",
    "license": "GPL-3.0-or-later",
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.6",
        "cakephp/cakephp": "3.5.*"
    }
}

My repository contains just one file for testing. What is wrong? I tried to remove the dependencies, the entire "require"-block, but no real change...

Beginner as I am, I don't even know where I would define the packages "stability", can't find anything at github or at packagist.

Please help me get this started!


Working solution:

I eventually got it working with the help from Flying, see his answer further down. Since I think it is a wee bit complicated to get composer up'n working, I try to put the steps I did to get it working here:

  1. Create a repository at github.
  2. Create a composer.json with your depencencies. Check it in.
  3. Release it. There are a "Releases" link somewhere, use it and give the release a name.

Now, to skip the packagist.org step during your testing, follow these steps. It is not good style to publish a non-working solution (like I did) on packagist.org, and it's no fun at all to do all the steps necessary ten times over.

Create a local folder somewhere, and create a new composer.json file there.

Put something like this in it:

{
  "require": {
    "madskullcreations/simplicity":"dev-master@dev"
  },
  "repositories": [
    {
       "type": "vcs",
       "url": "https://github.com/madskullcreations/simplicity" 
    }
  ]
}

Run the following command in your new folder:

composer create-project

It should now download and install your project.

And, read the error messages given by composer and make sure you understand them. They are useful. My headache was a missing PHP-extension (intl) and that I assumed it was using php version 7.1, while it actually listened to my requirement in the composer.json file, and used v5.6. (I have several php-versions installed in iis, but my fuzzy head did not consider that.)

like image 591
Snorvarg Avatar asked Dec 30 '17 13:12

Snorvarg


1 Answers

Packages stability requirement is defined into minimum-stability setting of composer.json of your project, not a composer.json of the external package.

Your madskullcreations/simplicity package have no releases defined so the only branch that is available in it - is dev-master "release" (it can be seen at the right side of package page on Packagist). This "release" have "dev" stability level.

Because of above if you're requiring this package into your project without either setting minimum-stability: dev or without specifying stability requirement for a package as

"require": {
  "madskullcreations/simplicity":"dev-master@dev"
} 

(notice @dev into version requirement) it is correct behavior of Composer to complain about lack of compatible releases.

Also it is generally bad practice to publish your test packages into public registry like Packagist. Instead you should use direct repository specification into your composer.json as explained here. In your case it will be:

"repositories": [
  {
     "type": "vcs",
     "url": "https://github.com/madskullcreations/simplicity" 
  }
]

After specifying direct repository reference - it will be safe to remove your test package from Packagist unless you're really want to share it with open source community.

like image 134
Flying Avatar answered Oct 19 '22 07:10

Flying