Requesting to install specific major version with ^ symbol doesn't check compatibility
michalsitek opened this issue · comments
Version of install-php-extensions
2.1.62
Error description
I'm using install-php-extensions v2.1.62 in a PHP 7.4.33 project to install Xdebug major version 3. PHP 7.4 is supported by Xdebug up to v3.1: https://xdebug.org/docs/compat
When I run:
install-php-extensions xdebug-^3
I get error message:
### INSTALLING REMOTE MODULE xdebug ###
(installing version 3.3.0alpha3)
pecl/xdebug requires PHP (version >= 8.0.0, version <= 8.3.99), installed version is 7.4.33
No valid packages found
install failed
When I install Xdebug without any version requirement, the latest supported version 3.1.6 is being installed. However, when there's a major version requirement, like ^3
, install-php-extensions doesn't choose a valid extension candidate based on PHP compatibility and it uses just the latest possible version matching the constraint ^3
.
Docker image
php:7.4.33-fpm-alpine3.16
Minimal Dockerfile
FROM php:7.4.33-fpm-alpine3.16
COPY --from=mlocati/php-extension-installer:2.1.62 /usr/bin/install-php-extensions /usr/local/bin/
install-php-extensions xdebug-^3
install-php-extensions
doesn't inspect package.xml
files in order to determine the compatible versions.
When you use ^
(for example: xdebug-^3
), the script:
- fetches the
allreleases.xml
files hosted on the PECL website (example for xdebug) - iterates all the found versions (
<v>
tags) and uses the first one that matches the wanted major version (which is the most recent accordingly to "semver" - see php/web-pecl#92)
Back to the xdebug example: because the greater version of xdebug 3 is 3.3.0alpha3
(greater than 3.2.2
), you'll get it.
I am going to add support for specifying the wanted stability (that is, you may want to use xdebug-^3@stable
)
Thank you for fast response.
The problem isn't necessarily that the version being installed is alpha instead of stable. It seems I accidentally exposed different issue. Now with the version 2.1.64 the output from
install-php-extensions xdebug-^3@stable
is
### INSTALLING REMOTE MODULE xdebug ###
(installing version 3.2.2)
pecl/xdebug requires PHP (version >= 8.0.0, version <= 8.2.99), installed version is 7.4.33
No valid packages found
install failed
How can I approach the compatibility issue? Would you like me to do some PoC or maybe you're not planning introducing such a feature in this project at all?
or maybe you're not planning introducing such a feature in this project at all?
This second case.
The reasons?
- I'm doing a really hard work to let
install-php-extensions
install the most recent version of every extension that's compatible with the PHP version (see for example the xdebug section). - Implementing what you need would potentially require to download, extract and check many .tar.gz archives (for example, in your case we'd have to do that for versions 3.2.2, 3.2.1, 3.2.0, and finally 3.1.6)
- if you manually specify a version requirement (eg
^3
), I suppose you know what you are doing (and in your case accordingly to the xdebug docs I'd use^3.1
)
Implementing what you need would potentially require to download, extract and check many .tar.gz archives (for example, in your case we'd have to do that for versions 3.2.2, 3.2.1, 3.2.0, and finally 3.1.6)
I think all the necessary data is already there. Those default versions like here are the highest supported ones.
Correct me if I'm wrong, but having such an information should be enough for all the purposes. Let's consider following cases:
- I request to install hypotethical version 4 of xdebug with
xdebug-^4
, major version is higher than the last supported one, so an error is thrown without attempting to install - I request to install
xdebug-^3
on PHP 7.4 - latest version matching the constraint (3.2.2) is higher than the last supported one (3.1.6), so that one will be installed instead, as it still fits into the^3
constraint - I request to install
xdebug-^3.2
on PHP 7.4 - latest version matching the constraint is higher than the last supported one (3.1.6) and version 3.1.6 doesn't fit into^3.2
constraint, so an error is thrown without attempting to install - I request to install
xdebug-^2
- major version is lower than the last supported one, so installation proceeds without further checks
What do you think?
I think that it's overly complicated (the script is already a mess)