3
votes

I have a project with composer that requires vendor/package-1 in the main project composer.json file, vendor/package-1 requires vendor/package-2 in the composer.json of the package-1. I have currently installed version 1.18.11 of vendor/package-1 and version 2.3.2 of vendor/package-2. I want to update to new vendor/package-1 version 1.19.* (that requires version 2.4.* from vendor/package-2) and executing:

composer require vendor/package-1:1.19.*

Fails and the output I get is

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
    - vendor/package-1 v1.19.2 requires vendor/package2 2.4.* -> satisfiable by vendor/package2[v2.4.3, v2.4.0, v2.4.1, v2.4.2].
    - vendor/package-1 v1.19.1 requires vendor/package2 2.4.* -> satisfiable by vendor/package2[v2.4.3, v2.4.0, v2.4.1, v2.4.2].
    - vendor/package-1 v1.19.2 requires vendor/package2 2.4.* -> satisfiable by vendor/package2[v2.4.3, v2.4.0, v2.4.1, v2.4.2].
    - Can only install one of: vendor/package2[v2.3.2, v2.4.3].
    - Can only install one of: vendor/package2[v2.4.0, v2.3.2].
    - Can only install one of: vendor/package2[v2.4.1, v2.3.2].
    - Can only install one of: vendor/package2[v2.4.2, v2.3.2].
    - Can only install one of: vendor/package2[v2.4.3, v2.3.2].
    - Installation request for vendor/package2 == 2.3.2.0 -> satisfiable by vendor/package2[v2.3.2].
    - Installation request for vendor/package-1 1.19.* -> satisfiable by vendor/package-1[v1.19.1, v1.19.2].

Installation failed, reverting ./composer.json to its original content.

Does the composer require command need to be specified for all the dependencies? If I try

composer require vendor/package-1:1.19.* vendor/package-2:2.4.*

It works but it shouldn't be necessary to specify every dependency, right?

2

2 Answers

3
votes

It seems like vendor/package2 is require in a fixed version as 2.3.2 or 2.3.* and cannot be updated to 2.4.

Generally you should try to relax the version requirements to allow for compatible updates. Use the tilde operator for this, require the package2 as ~2.3 (minimum 2.3, update as long as it's not the incompatible version 3). The same applies to package1 as well: If you need the features that are included in the 1.19 line, you'd require ~1.19.

3
votes

This should be possible with:

composer require vendor/package-1:1.19.* --update-with-dependencies