shivammathur / setup-php

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.
https://setup-php.com
MIT License
2.93k stars 352 forks source link

PHP 8.1 - Module "redis" is already loaded #874

Closed jrchamp closed 1 month ago

jrchamp commented 1 month ago

Describe the bug Getting PHP warning during the setup-php action and subsequent PHP processes: PHP Warning: Module "redis" is already loaded in Unknown on line 0

This breaks the moodlehq/moodle-plugin-ci because PHP warnings are not allowed during CI tests.

Version

Runners

Operating systems

ubuntu-latest (ubuntu-22.04)

PHP versions

This is only a problem on PHP 8.1. PHP 7.2, 7.4, 8.0, 8.2 and 8.3 all succeed.

To Reproduce

name: Moodle Plugin CI

on: [push, pull_request]

jobs:
  test:
    runs-on: 'ubuntu-latest'

    strategy:
      matrix:
        include:
          - php: '8.1'

    steps:
      - name: Setup PHP ${{ matrix.php }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: ${{ matrix.extensions }}
          ini-values: max_input_vars=5000
          coverage: none

Expected behavior

No PHP warnings.

Screenshots/Logs

Runner:

Current runner version: '2.320.0'
Operating System
  Ubuntu
  22.04.5
  LTS
Runner Image
  Image: ubuntu-22.04
  Version: 20241006.1.0

Download action repository 'shivammathur/setup-php@v2' (SHA:c541c155eee45413f5b09a52248675b1a2575231)

Run shivammathur/setup-php@v2
  with:
    php-version: 8.1
    ini-values: max_input_vars=5000
    coverage: none
    ini-file: production
/usr/bin/bash /home/runner/work/_actions/shivammathur/setup-php/v2/src/scripts/run.sh
==> Setup PHP
✓ PHP Updated to PHP 8.1.30
==> Setup Tools
PHP Warning:  Module "redis" is already loaded in Unknown on line 0
✓ composer Added composer 2.8.1
==> Setup Coverage
✓ none Disabled Xdebug and PCOV
==> Add php.ini values
✓ max_input_vars=5000 Added to php.ini
==> Sponsor setup-php
✓ setup-php https://setup-php.com/sponsor

Additional context

Are you willing to submit a PR?

I don't know how to fix the problem, but I'd be happy to submit a PR if that would help.

Bockiii commented 1 month ago

Hi,

same thing is happening over in our repo. Started today. https://github.com/RSS-Bridge/rss-bridge/issues/4299

jrchamp commented 1 month ago

I ran a test with some extra steps:

      - name: Check for redis files before setup-php
        if: ${{ !cancelled() }}
        run: find /etc/php -name \*redis\*

      - name: Setup PHP ${{ matrix.php }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: ${{ matrix.extensions }}
          ini-values: max_input_vars=5000
          coverage: none

      - name: Check for redis files after setup-php
        if: ${{ !cancelled() }}
        run: find /etc/php -name \*redis\*

Output:

Run find /etc/php -name \*redis\*
/etc/php/8.1/phpdbg/conf.d/20-redis.ini
/etc/php/8.1/cgi/conf.d/20-redis.ini
/etc/php/8.1/mods-available/redis.ini
/etc/php/8.1/cli/conf.d/20-redis.ini
/etc/php/8.1/fpm/conf.d/20-redis.ini

Run find /etc/php -name \*redis\*
/etc/php/8.1/phpdbg/conf.d/20-redis.ini
/etc/php/8.1/phpdbg/conf.d/25-redis.ini
/etc/php/8.1/cgi/conf.d/20-redis.ini
/etc/php/8.1/cgi/conf.d/25-redis.ini
/etc/php/8.1/mods-available/redis.ini
/etc/php/8.1/embed/conf.d/25-redis.ini
/etc/php/8.1/cli/conf.d/20-redis.ini
/etc/php/8.1/cli/conf.d/25-redis.ini
/etc/php/8.1/fpm/conf.d/20-redis.ini
/etc/php/8.1/fpm/conf.d/25-redis.ini

So it looks like setup-php is adding extra redis.ini files with a "run order" of 25 which duplicates the pre-existing run order of 20 which is pre-installed on the GitHub Hosted runner images.

shivammathur commented 1 month ago

Looking into this

jrchamp commented 1 month ago

@oerdnj released a new version of the php-redis package last week. One of the changes is "Change priority of redis extension loading to 25"

shivammathur commented 1 month ago

For anyone facing this.

For ubuntu-22.04 and ubuntu-24.04, this has been fixed in https://github.com/shivammathur/php-ubuntu/commit/edd8d435d02e4351f946b5502d4759ba9c2eae2a and no action is required.

For ubuntu-20.04, please set the env update: true in your workflow and that should fix it.

Bockiii commented 1 month ago

The fix for ubuntu-20.04 worked! Thanks a lot!