6
votes

I have a package that I have installed through composer that required guzzlehttp >=6.0. With that requirement, composer chose to install 6.2.1.

I am now trying to require a dependency that explicitly requires 6.1.1.

I get the following error: Problem 1 - Can only install one of: guzzlehttp/guzzle[6.1.1, 6.2.1]. - Can only install one of: guzzlehttp/guzzle[6.2.1, 6.1.1]. - Can only install one of: guzzlehttp/guzzle[6.1.1, 6.2.1]. - chargely/chargify-sdk-php v0.1.1 requires guzzlehttp/guzzle 6.1.1 -> satisfiable by guzzlehttp/guzzle[6.1.1]. - Installation request for chargely/chargify-sdk-php ^0.1.1 -> satisfiable by chargely/chargify-sdk-php[v0.1.1]. - Installation request for guzzlehttp/guzzle (locked at 6.2.1) -> satisfiable by guzzlehttp/guzzle[6.2.1].

Also, composer why confirms that the only that version of guzzle is there is because of my >=6.0 requirement.

In theory, that initial requirement should be OK with using a downgraded version of guzzle. How do I get composer to do that?

2
What does your composer.json look like now?Tomas Votruba

2 Answers

10
votes

If you have 2 packages with concurrency requirements, you can go around with aliasing.

In your composer.json, just add:

"require": {
    "guzzlehttp/guzzle": "6.2 as 6.1"
}

Then add new package with composer require ....

Go check more detailed answer for more.

0
votes

Simply "require" the correct version of the dependency, add the new package and then remove the hard-coded version constraint.

Summary (For a vendor/current with a constraint of vendor/dependency:"^1.0|^2.0")

composer require vendor/dependency:^1.0
composer require vendor/new
composer remove vendor/dependency

e.g.

  1. For a vendor/current with a constraint of vendor/dependency:"^1.0|^2.0"
  2. Composer would install the highest compatible version vendor/dependency:2.x
  3. Then you try to install vendor/new with constraint of vendor/dependency:"^1.0" => FAIL (as you already have a too high installed vendor/dependency (of 2.0)
  4. So then manually get the correct vendor/dependency version composer require vendor/dependency:^1.0
  5. Get the new package composer require vendor/new
  6. Remove hard coded constraint in composer.json composer remove vendor/dependency
  7. Done.