60

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"
    }
}
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Antoine Bourlart
  • 781
  • 2
  • 6
  • 12

5 Answers5

44

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.

BVengerov
  • 2,947
  • 1
  • 18
  • 32
  • 1
    I have the same problem. I have a tag 1.1.0 available in my repo but composer is still saying I only have a dev-master release which is not even true, I have not any branch or tag with that name...?!? – Guillaume Bois Jan 17 '17 at 19:50
  • 2
    @GuillaumeBois Composer allows using branches as versions by specifying them as `dev-`, so `dev-master` relates to `master` branch. If you want to specify a specific tag, it goes like `"author/package": "dev-master#v1.1.0"`. See [this question](http://stackoverflow.com/questions/34784809/how-to-use-a-specific-tag-version-with-composer-and-a-private-git-repository) for details. – BVengerov Jan 18 '17 at 05:55
  • 14
    The problem was that my tag was `1.1.0` and should have been `v1.1.0` ! OMG I hate the computers... – Guillaume Bois Jan 19 '17 at 12:59
  • I had this problem because I had neglected to push my tag to the remote. It is probably also worth running composer clear-cache. – Russ Aug 23 '17 at 09:57
  • @BVengerov Is there a way to specify a specific branch? – crmpicco Jul 24 '18 at 07:53
  • @crmpicco basically prepend `dev-` prefix to the branch name - like in `dev-master` above. See [this question](https://stackoverflow.com/q/33525885/4725998) and it's answer as the reference. – BVengerov Jul 24 '18 at 11:24
  • @BVengerov Hmm, yes that's what I done however see my question here - https://stackoverflow.com/questions/51493884/composer-pull-dependency-from-another-branch-on-the-same-repo – crmpicco Jul 25 '18 at 01:02
  • 1
    For me, having "5.8.*" set in composer.json it always pulls 5.8.0 even though there's 5.8.1 tag in my remote repo ... Any ideas? :o But If I put 5.8.1 directly I get an error: Problem 1 - The requested package myrepo/advanced-custom-fields-pro v5.8.1 exists as myrepo/advanced-custom-fields-pro[v5.8.0] but these are rejected by your constraint. Any help appreciated. – trainoasis Jun 14 '19 at 12:12
  • @trainoasis maybe my answer here helps you as well. Took me an hour to figure out. – Tum Sep 04 '20 at 14:38
14

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.

MikeiLL
  • 6,282
  • 5
  • 37
  • 68
9

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 :)

OllieLowson
  • 99
  • 1
  • 4
  • Where did you remove the version element? I dont have any and this happens for a private bitbucket repo – trainoasis Jun 14 '19 at 12:06
  • You are correct, the other solution is to tag the version in your repo with the correct version number and it would work also – Mohamed Saleh Jul 27 '20 at 21:37
3

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.

sibaz
  • 1,242
  • 14
  • 26
3

After searching a while I found out the repository was missing in my composer file. Someone removed it, so therefore only previous versions worked.

...

"require": {
    "company/my-repo": "*"
}

...

"repositories": [
    {
        "type": "vcs",
        "url": "git@bitbucket.org:company/my-repo.git"
    },
],

...
Tum
  • 6,937
  • 2
  • 25
  • 23