Is there a fix for “Option “–coverage” is ambiguous.” in PestPHP in Bitbucket pipelines?

Running the custom test in the following configuration results in the message
Option "--coverage" is ambiguous. followed by failure in the pipeline.

image:
  name: php:8.3-cli-bookworm
definitions:
  services:
    mysql:
      image: mysql/mysql-server:8.0
      variables:
        MYSQL_DATABASE: "testing"
        MYSQL_RANDOM_ROOT_PASSWORD: "yes"
        MYSQL_USER: "test_user"
        MYSQL_PASSWORD: "test_user_password"
  caches:
    composer:
      key:
        files:
          - composer.json
          - composer.lock
      path: vendor
  steps:
    - step: &composer-install
        name: Install dependencies
        caches:
          - composer
        script:
          - apt-get update && apt-get install -yq wget git zip unzip libfreetype6-dev libjpeg62-turbo-dev libpng-dev
          - docker-php-ext-configure gd --with-freetype --with-jpeg
          - docker-php-ext-install -j$(nproc) gd
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install --no-progress
    - step: &phpstan
        name: PHPStan
        caches:
          - composer
        script:
          - vendor/bin/phpstan analyze -c phpstan.neon --memory-limit=1G
    - step: &pint
        name: Pint
        caches:
          - composer
        script:
          - vendor/bin/pint
    - step: &code_coverage
        name: Pest Code Coverage
        caches:
          - composer
        script:
          - apt-get update && apt-get install -yq zlib1g-dev libicu-dev g++
          - pecl install xdebug
          - docker-php-ext-configure intl
          - docker-php-ext-enable xdebug
          - docker-php-ext-install -j$(nproc) intl pdo_mysql
          - echo "xdebug.mode=debug,coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
          - echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
          - echo 'memory_limit = 512M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini
          - echo 'DB_USERNAME=test_user' >> .env
          - echo 'DB_PASSWORD=test_user_password' >> .env
          - echo 'APP_URL=http://localhost' >> .env
          - echo 'APP_KEY=' >> .env
          - php artisan key:generate
          - php artisan passport:keys
          - vendor/bin/pest --coverage --min=100
        services:
          - mysql
pipelines:
   custom:
    test:
      - step: *composer-install
      - parallel:
          steps:
            - step: *phpstan
            - step: *code_coverage
            - step: *pint

I have found the following issues related to this:

But I’m afraid following the suggestions in that thread had no effect for me.

I’ve tried adding - export COMPOSER_ALLOW_SUPERUSER=1 and - composer config allow-plugins.pestphp/pest-plugin before - composer install --no-progress.

Running these commands in a local docker container set up like this works like a charm:

# pipeline_test.Dockerfile

# syntax = docker/dockerfile:1.2
FROM php:8.3-cli-bookworm

WORKDIR /app
COPY . /app
docker run --network=host --name mysql  
-e MYSQL_DATABASE='testing' 
-e MYSQL_RANDOM_ROOT_PASSWORD='yes' 
-e MYSQL_USER='test_user' 
-e MYSQL_PASSWORD='test_user_password' 
-d mysql/mysql-server:8.0

docker build --memory=1g --memory-swap=1g -t pipeline_test/pipeline_test:latest -f pipeline_test.Dockerfile . &&
docker run -it --network=host --memory=4g --memory-swap=4g --memory-swappiness=0 --cpus=4 --entrypoint=/bin/bash pipeline_test/pipeline_test:latest

I think my problem is due to a composer update which prevents scripts from being installed by the root user or the sudo command. Does anyone know how to rewrite my pipeline to work with the new composer version?