11

The following composer.json:

{
    "type": "project",
    "minimum-stability": "dev",
    "require": {
        "jasny/bootstrap": ">=3.1.3",
        "2amigos/yii2-file-input-widget": "*"
    }
}

leads to the following output of composer update:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.                               

  Problem 1
    - 2amigos/yii2-file-input-widget 0.1.2 requires jasny/bootstrap v3.1.0 -> satisfiable by jasny/bootstrap[v3.1.0] but these conflict with your requirements or minimum-stability.
    - 2amigos/yii2-file-input-widget 0.1.1 requires jasny/bootstrap v3.1.0 -> satisfiable by jasny/bootstrap[v3.1.0] but these conflict with your requirements or minimum-stability.
    - 2amigos/yii2-file-input-widget 0.1.0 requires jasny/bootstrap v3.1.0 -> satisfiable by jasny/bootstrap[v3.1.0] but these conflict with your requirements or minimum-stability.
    - 2amigos/yii2-file-input-widget 1.0.0 requires jasny/bootstrap ~3.1.0 -> satisfiable by jasny/bootstrap[v3.1.3].
    - 2amigos/yii2-file-input-widget 1.0.1 requires jasny/bootstrap ~3.1.0 -> satisfiable by jasny/bootstrap[v3.1.3].
    - 2amigos/yii2-file-input-widget 1.0.2 requires jasny/bootstrap ~3.1.0 -> satisfiable by jasny/bootstrap[v3.1.3].
    - 2amigos/yii2-file-input-widget dev-master requires jasny/bootstrap ~3.1.0 -> satisfiable by jasny/bootstrap[v3.1.3].
    - 2amigos/yii2-file-input-widget 1.0.x-dev requires jasny/bootstrap ~3.1.0 -> satisfiable by jasny/bootstrap[v3.1.3].
    - Conclusion: don't install jasny/bootstrap v3.1.3
    - Installation request for 2amigos/yii2-file-input-widget * -> satisfiable by 2amigos/yii2-file-input-widget[0.1.0, 0.1.1, 0.1.2, 1.0.0, 1.0.1, 1.0.2, dev-master, 1.0.x-dev].

Why?


Ok, I understand, why versions 0.1.0–0.1.2 of 2amigos/yii2-file-input-widget can't be installed — because they require jasny/bootstrap of exact version 3.1.0, which conflicts with >=3.1.3 requirement in composer.json (and therefore composer clarifies: but these conflict with your requirements or minimum-stability).

But, from common-sense view, composer can install version 1.0.0 or later of 2amigos/yii2-file-input-widget (which requires jasny/bootstrap of version ~3.1.0, which is satisfiable by 3.1.3). Neither I see any obstacles for installing 2amigos/yii2-file-input-widget 1.0.0+ together with jasny/bootstrap 3.1.3, nor composer writes any explicit clarification about it. Still it says: Conclusion: don't install jasny/bootstrap v3.1.3 — why?

Workaround 1

It seems it works with "prefer-stable": true.

Workaround 2

I actually found the other workaround some time ago: I replace "2amigos/yii2-file-input-widget": "*" with "2amigos/yii2-file-input-widget": "1.0.2", do composer update and then replace it back and do composer update again — and it works.


The question is why it works in so strange way: why it works with more restrictions, but fails with less restrictions (with no clarification). E.g. if it works with 1.0.2 (or with prefer-stable) works — then why it doesn't with * (or without prefer-stable)?

4
  • Can you show your composer.json?
    – localheinz
    Commented Jul 11, 2017 at 6:25
  • @localheinz, excerpt from require section from composed.json is in the beginning of the question. Do some other sections matter?
    – Sasha
    Commented Jul 11, 2017 at 9:06
  • Have you tried adding "prefer-stable": true to composer.json? See getcomposer.org/doc/04-schema.md#prefer-stable.
    – localheinz
    Commented Jul 11, 2017 at 13:12
  • @localheinz, yes, it works with "prefer-stable": true. I actually found the other workaround some time ago: I replace "2amigos/yii2-file-input-widget": "*" with "2amigos/yii2-file-input-widget": "1.0.2", do composer update and then replace it back and do composer update again — and it works. The question is why it works in so strange way: why it works with more restrictions, but fails with less restrictions (with no clarification). E.g. if it works with "1.0.2" (or with prefer-stable) works — then why it doesn't with "*" (or without prefer-stable)?
    – Sasha
    Commented Jul 11, 2017 at 14:20

2 Answers 2

5

Change the order and it should work, e.g.

{
    "minimum-stability": "dev",
    "require": {
        "2amigos/yii2-file-input-widget": "*",
        "jasny/bootstrap": ">=3.1.3"
    }
}

Why? I don't know. Most likely a Composer's bug.

I've tested two configurations with different order on the empty folder using composer install command (Composer v1.6.3), the original order fails, however the order above works. I've reported the issue at GH-7215.

1
  • 1
    Thanks. I've actually found a similar report right now: 5780. But it was incomplete at the time of its creation and therefore closed.
    – Sasha
    Commented Mar 25, 2018 at 16:45
0

The problem might well be that you are manually editing composer.json and then running

$ composer update

Instead, revert the changes to composer.json and then run:

$ composer require jasny/bootstrap:>=3.1.3
$ composer require "2amigos/yii2-file-input-widget:*"

or in one go:

$ composer require jasny/bootstrap:>=3.1.3 "2amigos/yii2-file-input-widget:*"

Note I recommend to avoid the * wildcard as version constraint because it could pull in any version of that dependency, and potentially break your application by pulling in a version that is not compatible with it.

For reference, see:

1
  • Fails with same error message. BTW, when I run composer require "jasny/bootstrap:>=3.1.3" "2amigos/yii2-file-input-widget:*", it somewhy adds "2amigos/yii2-file-input-widget" : "1.0.x-dev" (not "2amigos/yii2-file-input-widget" : "*") into the composer.json (but then restores composer.json, as command failed).
    – Sasha
    Commented Jul 11, 2017 at 15:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.