Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer create-project doesn't check platform requirements #11697

Open
joachim-n opened this issue Oct 27, 2023 · 5 comments
Open

Composer create-project doesn't check platform requirements #11697

joachim-n opened this issue Oct 27, 2023 · 5 comments
Labels
Milestone

Comments

@joachim-n
Copy link

My composer.json:

...replace me...

Output of composer diagnose:

Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK git version 2.42.0
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 2.6.5
PHP version: 8.2.0
PHP binary path: /Applications/MAMP/bin/php/php8.2.0/bin/php
OpenSSL version: OpenSSL 1.0.2u  20 Dec 2019
cURL version: 7.68.0 libz 1.2.11 ssl OpenSSL/1.0.2u
zip: extension present, unzip present, 7-Zip not available

When I run this command on PHP 8.2:

composer create drupal/recommended-project composer-bug-repro 9.5

everything installs as expected. However, subsequent composer commands complain. E.g doing:

composer require drush/drush:*

outputs:

    - laminas/laminas-diactoros 2.14.0 requires php ^7.3 || ~8.0.0 || ~8.1.0 -> your php version (8.2.0) does not satisfy that requirement.

Checking this package:

composer why laminas/laminas-diactoros
drupal/core             9.5.0 requires laminas/laminas-diactoros (^2.14)
drupal/core-recommended 9.5.0 requires laminas/laminas-diactoros (~2.14.0)

Shows that it was installed as part of the original create-project.

And I expected this to happen:

Don't install the project in the first place if a package won't work on the platform.

@xabbuh
Copy link
Contributor

xabbuh commented Oct 27, 2023

The composer.lock file of that project contains this:

    "platform-overrides": {
        "php": "7.3.0"
    },

Could that be the root issue?

@stof
Copy link
Contributor

stof commented Oct 27, 2023

This would indeed explain why the create-project command would not complain about PHP 8.2

@joachim-n
Copy link
Author

What is there in the drupal/recommended-project template which would have resulted in that in composer.lock?

@fredden
Copy link
Contributor

fredden commented Oct 27, 2023

What is there in the drupal/recommended-project template which would have resulted in that in composer.lock?

It looks like it's in the composer.lock file in the repository itself. https://github.com/drupal/recommended-project/blob/9.5.11/composer.lock#L4759-L4761

Running composer update in the project works, and removes that entry from composer.lock.

@Seldaek
Copy link
Member

Seldaek commented Dec 22, 2023

Right, I'm guessing whatever builds the release sets composer config platform.php 7.3.0 to ensure locked dependencies match that minimum PHP requirement. But then it's not added to the committed composer.json.

I'm not sure what to do about this.. If the composer.json does not have the overrides anymore we probably could warn when running an install, just not sure how much work this would be.

Really the best way would be to avoid shipping a lock file IMO and let dependency resolution happen at create-project time.

@Seldaek Seldaek added the Bug label Dec 22, 2023
@Seldaek Seldaek added this to the Bugs milestone Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants