Composer - The requested package exists as but these are rejected by your constraint

六眼飞鱼酱① 提交于 2019-12-03 04:43:30

问题


When I run my install from composer, I have this error :

λ composer install You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.

Error :

Problem 1 - The requested package antoineb1/smoney_bundle 1.0 exists as antoineb1/smoney_bundle[dev-master] but these are rejected by your constraint.

My composer.json

{
    "name": "project",
    "license": "proprietary",
    "type": "project",
    "minimum-stability": "dev",
    "prefer-stable" : true,
    "autoload": {
        "psr-4": {
            "": "src/"
        }
    },
    "config": {
        "preferred-install": "dist"
    },
    "repositories": [
        {
            "url": "bitbucket url",
            "type": "vcs"
        }
    ],
    "require": {
        "php": ">=5.5.9",
        "antoineb1/smoney_bundle": "1.0"
    }
}

回答1:


The version constraint "1.0" is interpreted internally as "1.0.0.0-stable" version.

But the only version available is:

antoineb1/smoney_bundle[dev-master].

So you could change the specified version to either one of the following depending on what version is suitable for you:

  • 1.0.* (which is seen by composer as >=1.0.0.0-dev <1.1.0.0-dev -- probably won't work because there obviously aren't any versions in that package)
  • dev-master
  • dev-master#<hash>
  • @dev
  • etc.

See the composer schema for reference.




回答2:


The comment by @Guillaume below this answer deserves a larger presentation.

It seems that composer wants a git release that has a v in it.

So it should be v1.1.0 and not 1.1.0.

I spent about 90 minutes looking at

mikeill/my_repo 3.3.10 requires composer/installers 1.0.*@dev -> satisfiable by composer/installers[1.0.x-dev, v1.0.0, ...] but these conflict with your requirements or minimum-stability.

And a lot of github issues as well as an SO post or two before finally discovering this thread.




回答3:


I lost a significant amount of hair, time and sanity over this question for a while - it turned out that the problem in my case was that I was specifying a version in the composer.json within the package itself as "dev-master".

Refer to: https://getcomposer.org/doc/04-schema.md#version

Where it states:

Note: Packagist uses VCS repositories, so the statement above is very much true for Packagist as well. Specifying the version yourself will most likely end up creating problems at some point due to human error.

(emphasis mine)

I removed this version element and it worked perfectly :)




回答4:


I came across this question, and found another issue, which I had completely forgotten about, which someone may find useful to have to check.

In my case I had a very old git project, which had been forked some time back, and I had to merge them together (albeit the forked project hadn't had many changes). So I identified the split point on the old project, and tagged it as version for composer, so I could use that in place of the new project.

What I had forgotten though, was that originally we didn't use composer. So the file structure at the tag point was missing composer.json. I couldn't figure out why my new tags weren't appearing on the 'exists as' list of things which were 'rejected by your contraint'. Eventually I realised I had to create a branch on the old tag, cherry-pick the commit which created the composer.json for the project, and retag that, and then it all worked.

Hopefully this will jog someones memory, if they come hunting with this error message in mind.



来源:https://stackoverflow.com/questions/39974833/composer-the-requested-package-exists-as-but-these-are-rejected-by-your-constr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!