Home > Software design >  Composer in Alpine Docker PHP Fatal error
Composer in Alpine Docker PHP Fatal error

Time:04-06

I am running docker pipelines with alpine 3.15 and PHP 7.0 and 7.1 on an ARM64.

I install composer using

COPY --from=composer:latest  /usr/bin/composer /usr/bin/composer

Since yesterday, 5th of April, all pipelines fail with the following error:

PHP Fatal error: Declaration of Composer\IO\BaseIO::hasAuthentication($repositoryName) must be compatible with Composer\IO\IOInterface::hasAuthentication(string $repositoryName) in phar:///usr/bin/composer/src/Composer/IO/BaseIO.php on line 20

I tried using older versions of composer, but on all them I get:

Segmentation fault

This was working fine for the past 6 months. So something changed recently on the composer builds. I also tried running on Intel and to install the composer the classical way, however, I also get the same errors.

CodePudding user response:

You are installing composer:latest, which as of today will install Composer 2.3. And you are doing it on PHP 7.0 and PHP 7.1.

Those PHP versions are no longer supported by Composer 2.3 (nor by PHP, for what it's worth).

As announced in the 2.2 release notes, Composer 2.3 increases the required PHP version to >=7.2.5 and thus stops supporting PHP 5.3.2 - 7.2.4. The 2.2 LTS is still there for users stuck on older PHP versions.

Your options are:

  • Upgrade PHP so use something supported. If you have to remain in v7, you can at least upgrade to PHP 7.4
  • Use an older version of composer. Instead of an unconstrained "latest" tag, point to a specific one you know it's supported.

You can try with version 2.2, which I think should work. If not, keep going backwards until you find one that works with your stack.

COPY --from=composer:2.2  /usr/bin/composer /usr/bin/composer
  • Related