composer
composer copied to clipboard
PHP 8.2 not working
Hey trying to use GitHub actions with a composer dependency to php 8.2, I get the following in the action:
Your Composer dependencies require a PHP version ">= 8.2.0". You are running 8.1.2-1ubuntu2.13.
PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0". You are running 8.1.2-1ubuntu2.13
This is the action
- name: Install dependencies
uses: php-actions/composer@v6
with:
php_version: '8.2'
php_extensions: gd zip sodium intl soap bcmath
dev: yes
Thanks for the info. Looking into it for you.
+1
Bumping this as PHP 8.1 active support ended a couple of weeks ago and this now blocks updates to 8.2 in consumer projects
So I had a close look into this action. Everything is working correctly. The version specified in the argument is correctly installed into a short-lived Docker container.
The reason why we receive the error is conceptual: we are using this package incorrectly. :)
This action runs in the runner container and starts it's own container where it runs composer commands. Then, that container is removed. The version of php in your runner container (the one you specify in runs-on: ubuntu-latest
) is what comes out-of-the-box with ubuntu-latest
and, most likely, is not what you want. The version of PHP you specify for this action applies only to the container this action creates, it has no effect on the "runner" container.
This action is intended to be used in conjunction with other actions that all perform their activities in the separate docker containers that are started and stopped after each action execution.
If you want to install php version on the runner itself, you would use shivammathur/setup-php
action instead.
Before:
- uses: php-actions/composer@v6
after
- uses: shivammathur/setup-php@v2
- run: composer install
Similar question was asked an answered in https://github.com/php-actions/composer/issues/111
@g105b
Maybe it is worth putting an explanation into README.md
file so that people would be informed about specifics of the running actions like this in the separate short-lived container.
Thank you for your detailed write up @AlexSkrypnyk - I agree with you. I will write some documentation that addresses this, because I think most new issues submitted here are to do with running something on the native PHP. I wonder if there's a better way to do this altogether, like link the php
binary to the one inside the php-actions container?