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.85k stars 334 forks source link

Warnings when using PHP 8.3 on self-hosted runners #842

Closed Sn0wCrack closed 1 month ago

Sn0wCrack commented 2 months ago

Describe the bug

Currently some of my self-hosted runners that have PHP 8.3 installed seem to output several warnigns about installed extensions failing to load in due to additionally missing linked libraries.

Some runners also seem to have slightly different PHP versions installed, with some having 8.3.0 and others having 8.3.6.

Version

Runners

Operating systems

Ubuntu 22.04.4 LTS

PHP versions

PHP 8.3

To Reproduce

Using PHP 8.3 on a self-hosted runner, unsure how this triggered in the first place for these runners.

Expected behavior

All required packages would be installed for these extensions

Screenshots/Logs

Output from running a PHP process on a server producing the error:

PHP Warning:  PHP Startup: Unable to load dynamic library 'amqp.so' (tried: /usr/lib/php/20230831/amqp.so (librabbitmq.so.4: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/amqp.so.so (/usr/lib/php/20230831/amqp.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'dba.so' (tried: /usr/lib/php/20230831/dba.so (liblmdb.so.0: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/dba.so.so (/usr/lib/php/20230831/dba.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'enchant.so' (tried: /usr/lib/php/20230831/enchant.so (libenchant-2.so.2: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/enchant.so.so (/usr/lib/php/20230831/enchant.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20230831/imagick.so (libMagickWand-6.Q16.so.6: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/imagick.so.so (/usr/lib/php/20230831/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'imap.so' (tried: /usr/lib/php/20230831/imap.so (libc-client.so.2007e: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/imap.so.so (/usr/lib/php/20230831/imap.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_dblib.so' (tried: /usr/lib/php/20230831/pdo_dblib.so (libsybdb.so.5: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/pdo_dblib.so.so (/usr/lib/php/20230831/pdo_dblib.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_firebird.so' (tried: /usr/lib/php/20230831/pdo_firebird.so (libfbclient.so.2: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/pdo_firebird.so.so (/usr/lib/php/20230831/pdo_firebird.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so' (tried: /usr/lib/php/20230831/pdo_sqlsrv.so (libodbcinst.so.2: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/pdo_sqlsrv.so.so (/usr/lib/php/20230831/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pspell.so' (tried: /usr/lib/php/20230831/pspell.so (libaspell.so.15: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/pspell.so.so (/usr/lib/php/20230831/pspell.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'snmp.so' (tried: /usr/lib/php/20230831/snmp.so (libnetsnmp.so.40: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/snmp.so.so (/usr/lib/php/20230831/snmp.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /usr/lib/php/20230831/sqlsrv.so (libodbcinst.so.2: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/sqlsrv.so.so (/usr/lib/php/20230831/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'tidy.so' (tried: /usr/lib/php/20230831/tidy.so (libtidy.so.5deb1: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/tidy.so.so (/usr/lib/php/20230831/tidy.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'zmq.so' (tried: /usr/lib/php/20230831/zmq.so (libzmq.so.5: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/zmq.so.so (/usr/lib/php/20230831/zmq.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'memcached.so' (tried: /usr/lib/php/20230831/memcached.so (libmemcached.so.11: cannot open shared object file: No such file or directory), /usr/lib/php/20230831/memcached.so.so (/usr/lib/php/20230831/memcached.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 8.3.6 (cli) (built: Apr 11 2024 00:27:27) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies
    with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans

The above output pretty much appears any time any PHP action occurs, from composer install, to starting our test runs.

Additional context

This only seems to affect two of my self-hosted runners for whatever reason and not the others, I'm imagining this is just an issue that occurred when these were installed.

I am also aware for PHP 8.3 it was switched to use a custom build of PHP rather than using ondrej's PHP builds, so that would be why it only affects PHP 8.3 in this case.

All runners would have started using PHP 8.3 around the same time as well, as only a single project began using it and it would have triggered on all of them probably within a week or so of that occurring.

These servers should have the same base set of packages installed as well, as we provisioned them all from a basic Ubuntu 22.04 LTS server image and use a bash script to install all the packages and setup the GitHub Runner service.

Are you willing to submit a PR?

If it's something I can fix then I would happy to take a further look.

shivammathur commented 2 months ago

@Sn0wCrack

Please provide the workflow you are using. Also please ensure that you are specifying runner env as self-hosted. https://github.com/shivammathur/setup-php?tab=readme-ov-file#self-hosted-setup

Sn0wCrack commented 2 months ago

It looks like I had some workflows that didn't have the self-hosted env, which is probably why this occurred.

I'll make this change and see if this resolves the issue by itself.

shivammathur commented 2 months ago

@Sn0wCrack Following up on this, were you able to fix it on your end.

Sn0wCrack commented 2 months ago

Sorry for not updating, had not had a change to test the changes after implementing them, took some time to go through all of our repositories as well, only a handful of workflows were missing the environment variable.

I've tested it again now after adding the runner environment variable and I still receive these warnings on those servers.

I'm assuming this fix won't be retroactive and I might have to manually remove the installed PHP 8.3 to have the action pull down the correct files again?

Here's my action workflow file for reference as well:

name: Continuous Integration

# Controls when the workflow will run
on:
  workflow_dispatch:
  push:
    branches: [ master ]
    paths:
      - '**.php'
      - '**.js'
      - '**.vue'
      - '**.ts'
      - '**.json'
      - '**.lock'
    tags-ignore:
      - 'v*'
  pull_request:
    branches: [ master ]
    paths:
      - '**.php'
      - '**.js'
      - '**.vue'
      - '**.ts'
      - '**.json'
      - '**.lock'

jobs:
  lint:
    runs-on: [ self-hosted, Linux, ci ]

    strategy:
      matrix:
        php-version: ['8.3']

    steps:
      - uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-version }}
          extensions: bcmath, ctype, fileinfo, json, mbstring, openssl, pdo, pdo_mysql tokenizer
          tools: composer
        env:
          runner: self-hosted

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          cache: 'yarn'
          node-version: 'lts/iron'

      - name: Install JavaScript Dependencies
        run: yarn install --frozen-lockfile

      - name: Install PHP Dependencies
        uses: ramsey/composer-install@v3

      - name: Lint JavaScript
        run: yarn lint

      - name: Lint PHP
        run: ./vendor/bin/pint --test

  test:
    runs-on: [ self-hosted, Linux, ci ]

    services:
      database:
        image: mariadb:10
        env:
          MYSQL_DATABASE: database
          MYSQL_ALLOW_EMPTY_PASSWORD: false
          MYSQL_ROOT_PASSWORD: password
        ports:
          - 3306
        options: >-
          --health-cmd="mysqladmin ping"
          --health-interval=10s
          --health-timeout=5s
          --health-retries=3

      cache:
        image: redis:7
        ports:
          - 6379

    strategy:
      matrix:
        php-version: ['8.3']

    steps:
      - uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-version }}
          extensions: bcmath, ctype, fileinfo, json, mbstring, openssl, pdo, pdo_mysql tokenizer, redis, igbinary, gd, imagick
          tools: composer
          coverage: pcov
        env:
          runner: self-hosted

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          cache: 'yarn'
          node-version: 'lts/iron'

      - name: Install JavaScript Dependencies
        run: yarn install --frozen-lockfile

      - name: Install PHP Dependencies
        uses: ramsey/composer-install@v3

      - name: Build JavaScript
        run: yarn dev

      - name: Setup tasks
        run: |
          touch .env
          php artisan storage:link

      - name: Run Tests
        run: php artisan test --coverage --parallel
shivammathur commented 2 months ago

Yes, it will require manually removing the previously installed version.