2

I'm trying to use Drupal.org's GitLab CI to test a module that has a dependency on a package that requires PHP's ext-sodium to be installed:

No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Root composer.json requires PHP extension ext-sodium * but it is missing from your system. Install or enable PHP's sodium extension.
  Problem 2
    - kreait/firebase-php[7.0.0, ..., 7.0.3] require lcobucci/jwt ^4.2.1 -> satisfiable by lcobucci/jwt[4.2.1, ..., 4.4.x-dev].
    - kreait/firebase-php[7.1.0, ..., 7.x-dev] require lcobucci/jwt ^4.3.0|^5.0 -> satisfiable by lcobucci/jwt[4.3.0, 4.3.x-dev, 4.4.x-dev, 5.0.0, ..., 5.4.x-dev].
    - lcobucci/jwt[4.2.1, ..., 4.4.x-dev, 5.0.0, ..., 5.4.x-dev] require ext-sodium * -> it is missing from your system. Install or enable PHP's sodium extension.
    - Root composer.json requires kreait/firebase-php ^7 -> satisfiable by kreait/firebase-php[7.0.0, ..., 7.x-dev].
To enable extensions, verify that they are enabled in your .ini files:
    - /usr/local/etc/php/php-cli.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-sodium` to temporarily ignore these required extensions.

source pipeline

I tried adding ext-sodium to the module's composer.json:

  "require": {
    "php": ">=8.1",
    "ext-sodium": "*",
    "kreait/firebase-php": "^7"
  },

But that doesn't help; I'm still getting the same error.

What's the proper approach to ensure that a PHP extension is enabled on Drupal.org's GitLab CI?

Update: It seems libsodium is uniquely a pain because it is now incorporated into PHP8.1. Issue here.

2 Answers 2

2

Adding to composer won't do - as the extension has to be available on the docker image thats building it.

in your gitlab-ci.yml

(https://git.drupalcode.org/project/firebase_php/-/blob/1.0.x/.gitlab-ci.yml?ref_type=heads)

look in to running a before script ... aka

before_script: 
 - apt-get update 
 - apt-get install libsodium13

see https://stackoverflow.com/questions/65598594/gitlab-php-docker-image-the-requested-php-extension-gd-is-missing-from-your-sy

for more

2

There is official documentation for adding extensions.

In .gitlab-ci.yml:

  before_script:
    - apt-get update
    - apt-get install -y --no-install-recommends $PHPIZE_DEPS
    - pecl install redis && docker-php-ext-enable redis

This line apt-get install -y --no-install-recommends $PHPIZE_DEPS is necessary because of the removal of some tooling from the Drupal GitLab CI images.

However, this won't work to install ext-sodium, because that is already bundled with PHP and can't be installed through pecl or docker-php-ext-enable on PHP 8.1+.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.