Skip to content

Dependency php-amqplib/php-amqplib vs php extension sockets causes inconsistent composer.lock file #27200

Closed
@hostep

Description

@hostep

Preconditions (*)

  1. Magento 2.4-develop branch
  2. PHP installation without the sockets extension installed

Steps to reproduce (*)

  1. Clone the 2.4-develop branch (I'm using commit 90012f2)
  2. Run composer install => notice it doesn't work:
$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - php-amqplib/php-amqplib v2.10.1 requires ext-sockets * -> the requested PHP extension sockets is missing from your system.
    - php-amqplib/php-amqplib v2.10.1 requires ext-sockets * -> the requested PHP extension sockets is missing from your system.
    - Installation request for php-amqplib/php-amqplib v2.10.1 -> satisfiable by php-amqplib/php-amqplib[v2.10.1].
  1. Run composer update php-amqplib/php-amqplib => notice now it suddenly works:
$ composer update php-amqplib/php-amqplib
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 40 updates, 0 removals
  - Downgrading php-amqplib/php-amqplib (v2.10.1 => v2.7.3): Loading from cache
...

--

Now use a PHP installation which does have the sockets extension installed and try again:

  1. Clone the 2.4-develop branch (I'm using commit 90012f2)
  2. Run composer install => notice it works

Expected result (*)

  1. Since the php extension sockets at this time is not required for a Magento installation, I would expect that we can install Magento without it installed

Actual result (*)

  1. Can only install Magento without the sockets extension installed when running composer update, not when running composer install

Discussion

  1. The big problem is that we now have the following constraint defined: "php-amqplib/php-amqplib": "~2.7.0||~2.10.0", in the composer.lock file
  2. php-amqplib/php-amqplib version 2.7 does not need sockets, version 2.10 does need sockets
  3. php-amqplib/php-amqplib requires the sockets extension since version 2.8.1

Solutions

Here are some possible solutions:

  1. Document that the sockets extension is required in the documentation and remove the constraint ~2.7.0|| from the composer.json file
  2. If we don't want the sockets extension to become required for Magento, we should change the constraint to: ~2.7.0
  3. Make all developers of Magento use the exact same PHP installation (I know this is not realistic), so that when they runcomposer update it doesn't suddenly upgrade php-amqplib/php-amqplib to a version which might not work on other people's installations
    (it was corrected in 3d223517139#diff-1da2c7edc898c70e5a79a9997c98ceccL1392 and then changed again in 9f14f89#diff-1da2c7edc898c70e5a79a9997c98ceccL1393)

Metadata

Metadata

Assignees

Labels

Component: ComponentIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P1Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing.Progress: doneReported on 2.4.0Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S1Affects critical data or functionality and forces users to employ a workaround.Triage: DoneHas been reviewed and prioritized during Triage with Product Managers

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions