Problem/Motivation

Would love to have the Sodium PHP extension in the build, for contrib modules that can use it (or require it).

CommentFileSizeAuthor
sodium.patch4.08 KBmfb

Comments

mfb created an issue. See original summary.

mfb’s picture

Status: Active » Needs review
Mixologic’s picture

Status: Needs review » Postponed (maintainer needs more info)

We dont add any extensions to the containers so that we dont end up in a situation where a feature in core accidentally uses an api that doesnt exist in core's minimum requirements.

If core is planning on changing requirements we can work on that then.

What do you need this for? It might be a good candidate for a gitlabCI job instead.

mfb’s picture

My use case is I maintain a couple modules that can optionally use Sodium extension if it's present, and ideally I'd like to be able to run tests both with and without Sodium extension.

I haven't looked into using gitlabCI on drupal.org yet but yes that should make it easy to e.g. build two different CI environments and run the tests in each.

Guess this issue should be closed if only extensions that core uses can be added.

mfb’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Closing this as works as designed - Sodium is intentionally missing.

Altho I've used GitLab CI heavily elsewhere, I am still blissfully ignorant how to use it w/ my drupal.org projects; someday I'll try to figure that out :)

yas’s picture

FYI, I tried to put a drupalci.yml file at the top directory on my project (drupal/cloud) for #3352839: Drupal 10 compatibility: Support drupal/simple_oauth:5.2 (by trying to add ext-sodium PHP library) because our dependent module drupal/simple_oauth requires a ext-sodium PHP library. They looked trying to switch GitLabCI instead at #3326143: Switch GitLab CI configuration to the template developed by the DA, however it means still we cannot use DrupalCI.

In my trial, drupalci.yml looks not solving the problem w/ the following error:

00:02:48.851 ----------------   Starting container_command   ----------------
00:02:48.856 Directory created at /var/lib/drupalci/workspace/jenkins-drupal8_contrib_patches-152186/ancillary/container_command
00:02:48.856 Container command.
00:02:48.856 sudo -u www-data docker-php-ext-install sodium
00:02:48.856 sudo -u www-data composer config platform.ext-sodium $PHP_VERSION --file=composer.json
00:02:48.856 
00:02:48.877 + cd sodium
00:02:48.877 + phpize
00:02:48.882 Configuring for:
00:02:48.882 PHP Api Version:         20210902
00:02:48.882 Zend Module Api No:      20210902
00:02:48.882 Zend Extension Api No:   420210902
00:02:48.883 mkdir: cannot create directory 'build': Permission denied
00:02:48.883 cp: target '/usr/src/php/ext/sodium/build' is not a directory
00:02:48.884 cp: cannot create regular file '/usr/src/php/ext/sodium/run-tests.php': Permission denied
00:02:48.884 /usr/local/bin/phpize: 154: cannot create configure.ac: Permission denied
00:02:48.885 chmod: cannot access '/usr/src/php/ext/sodium/build/shtool': No such file or directory
00:02:48.885 shtool at '/usr/src/php/ext/sodium/build/shtool' does not exist or is not executable.
00:02:48.885 Make sure that the file exists and is executable and then rerun this script.
00:02:48.885 
00:02:49.099 ---------------- Finished container_command in 0.248 seconds ----------------

We cannot install ext-sodium onto Docker container running on DrupalCI (?) Moreover, I found that we could insert our custom command as follows after PHP composer analyzes the dependencies and downloads the library. We want to run the following command before starting PHP composer:

      container_command:
        commands: |
          sudo -u www-data docker-php-ext-install sodium
          sudo -u www-data composer config platform.ext-sodium $PHP_VERSION --file=composer.json

Thanks

yas’s picture

UPDATE:

I wrote:

We cannot install ext-sodium onto Docker container running on DrupalCI (?)

I was wrong, it was successful to install ext-sodium by the following configuration of drupalci.yml:

      container_command:
        commands: |
          apt-get update && apt-get install -y libsodium-dev
          docker-php-ext-install sodium
          composer config platform.ext-sodium $PHP_VERSION --file=composer.json

In this case, I want to use --ignore-platform-ext=sodium option for PHP composer, but it didn't work even when I specify as follows:

  codebase:
    assemble_codebase:
      composer.install:
        options: 'install --ignore-platform-req=ext-sodium --prefer-dist --no-suggest --no-interaction --no-progress'
rhovland’s picture

To get composer to ignore the lack of the extension put this in the .gitlab-ci.yml file

variables:
  # Remove this once the base image includes the sodium PHP extension
  COMPOSER_EXTRA: '--ignore-platform-req=ext-sodium'
rhovland’s picture

Status: Closed (works as designed) » Needs review

Sodium is supposed to be part of newer versions of PHP, especially Debian. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911135
I know for certain it is installed by default in all supported versions of Ubuntu.

If we don't want it enabled by default that's fine, It can be enabled by adding the following once the module is included with PHP

.phpunit-base:
  before_script:
    - docker-php-ext-enable sodium

As it stands it is nearly impossible to enable sodium in php on the drupalci images because the dependencies to use docker-php-ext-install have been removed from the images, the package php-libsodium has been removed from debian, and the PECL module is not compatible with PHP 8.1 and newer.

rhovland’s picture

Status: Needs review » Closed (works as designed)

I just realized this is an issue for drupalci, not gitlabci. Closing.