setup-php
setup-php copied to clipboard
Changing PHP version disables extensions on self hosted runners
Describe the bug
- Create a single self hosted runner
- Run a workflow with PHP 7.4 on that runner
- Try to require a composer dependency that requires a PHP extension (examples: GD, SOAP BCMATH)
- Run a workflow with PHP 8.1 on that runner
- Require the same composer dependency again
- Now you will get an error, the PHP extensions that are required are disabled..
Version
- [x] I have checked releases, and the bug exists in the latest patch version of
v1
orv2
. - [x]
v2
- [ ]
v1
Runners
- [ ] GitHub Hosted
- [x] Self Hosted
Operating systems Ubuntu Focal
PHP versions I tested with PHP 7.4 and PHP 8.1
To Reproduce Try once with PHP 7.4 and once with PHP 8.1 using the same runner.
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ env.PHP_VERSION }}
tools: composer:v2
extensions: gd, bcmath, soap, pdo_mysql, ctype, curl, dom, hash, iconv, intl, mbstring, openssl, simplexml, xsl, sockets, zip
env:
runner: self-hosted
update: true
- name: Install composer dependencies
run: |
composer install --prefer-dist --no-interaction
Expected behavior The soap, bcmath and gd PHP extensions are enabled on both PHP 7.4 and PHP 8.1
Screenshots/Logs On the second run you will get the following error:
Error: Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- laminas/laminas-soap is locked to version 2.10.0 and an update of this package was not requested.
- laminas/laminas-soap 2.10.0 requires ext-soap * -> it is missing from your system. Install or enable PHP's soap extension.
Problem 2
- magento/framework is locked to version 103.0.4-p1 and an update of this package was not requested.
- magento/framework 103.0.4-p1 requires ext-bcmath * -> it is missing from your system. Install or enable PHP's bcmath extension.
Problem 3
- magento/module-shipping is locked to version 100.4.4 and an update of this package was not requested.
- magento/module-shipping 100.4.4 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension.
Problem 4
- magento/product-community-edition is locked to version 2.4.4-p1 and an update of this package was not requested.
- magento/product-community-edition 2.4.4-p1 requires ext-bcmath * -> it is missing from your system. Install or enable
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/8.1/cli/php.ini
- /etc/php/8.1/cli/conf.d/10-***nd.ini
- /etc/php/8.1/cli/conf.d/10-opcache.ini
- /etc/php/8.1/cli/conf.d/10-pdo.ini
- /etc/php/8.1/cli/conf.d/15-xml.ini
- /etc/php/8.1/cli/conf.d/20-calendar.ini
- /etc/php/8.1/cli/conf.d/20-ctype.ini
- /etc/php/8.1/cli/conf.d/20-curl.ini
- /etc/php/8.1/cli/conf.d/20-dom.ini
- /etc/php/8.1/cli/conf.d/20-exif.ini
- /etc/php/8.1/cli/conf.d/20-ffi.ini
- /etc/php/8.1/cli/conf.d/20-fileinfo.ini
- /etc/php/8.1/cli/conf.d/20-ftp.ini
- /etc/php/8.1/cli/conf.d/20-gettext.ini
- /etc/php/8.1/cli/conf.d/20-iconv.ini
- /etc/php/8.1/cli/conf.d/20-intl.ini
- /etc/php/8.1/cli/conf.d/20-mbstring.ini
- /etc/php/8.1/cli/conf.d/20-***i.ini
- /etc/php/8.1/cli/conf.d/20-pdo_***.ini
- /etc/php/8.1/cli/conf.d/20-pdo_pgsql.ini
- /etc/php/8.1/cli/conf.d/20-pgsql.ini
- /etc/php/8.1/cli/conf.d/20-phar.ini
- /etc/php/8.1/cli/conf.d/20-posix.ini
- /etc/php/8.1/cli/conf.d/20-readline.ini
- /etc/php/8.1/cli/conf.d/20-shmop.ini
- /etc/php/8.1/cli/conf.d/20-simplexml.ini
- /etc/php/8.1/cli/conf.d/20-sockets.ini
- /etc/php/8.1/cli/conf.d/20-sysvmsg.ini
- /etc/php/8.1/cli/conf.d/20-sysvsem.ini
- /etc/php/8.1/cli/conf.d/20-sysvshm.ini
- /etc/php/8.1/cli/conf.d/20-tokenizer.ini
- /etc/php/8.1/cli/conf.d/20-xmlreader.ini
- /etc/php/8.1/cli/conf.d/20-xmlwriter.ini
- /etc/php/8.1/cli/conf.d/20-xsl.ini
- /etc/php/8.1/cli/conf.d/20-zip.ini
- /etc/php/8.1/cli/conf.d/99-pecl.ini
-
Additional context
Are you willing to submit a PR?
@Tjitse-E Thanks for reporting this. I will have a look this weekend.
Fixed in https://github.com/shivammathur/setup-php/commit/7aff4d7a22a77f9733ffda9a5c414fa6043da9d1 Test workflow: https://github.com/shivammathur/test-setup-php/actions/runs/3030342518/workflow
Fixed in 7aff4d7 Test workflow: https://github.com/shivammathur/test-setup-php/actions/runs/3030342518/workflow
@shivammathur great! I just confirmed that this fixes the issue.
Released 2.22.0 with the fix.