I am getting very unusual issue. I have a drupal 9.2.18 site working with php 7.4
I want to update to php 8, initially i am trying to do at 8.0 instead of 8.1.
When I do composer update
it upgrade/downgrade few plugins due to php version check, it also updated composer api version to 2.3.0. Composer update works fine at my local instance. After that when I run composer install
on my local it works fine as well.
However when I upload code on eks server and build process start, composer install
fails. I troubleshooted and found the reason that vendor folder doesn't exists on server, composer install download all plugins from lock file and fails after line Updating dependencies.
I tried same scenario on local and able to reproduce the error.
PHP 8.0.17
Composer 2.3.5
Steps below
composer update
// works fine
rm -rf vendor
// remove vendor to simulate server
composer install
// fails as below error
PHP Fatal error: Declaration of Composer\DependencyResolver\Rule2Literals::getLiterals() must be compatible with Composer\DependencyResolver\Rule::getLiterals(): array in /cms/vendor/composer/composer/src/Composer/DependencyResolver/Rule2Literals.php on line 48
Fatal error: Declaration of Composer\DependencyResolver\Rule2Literals::getLiterals() must be compatible with Composer\DependencyResolver\Rule::getLiterals(): array in /cms/vendor/composer/composer/src/Composer/DependencyResolver/Rule2Literals.php on line 48
Edited: Composer version is 2.2.12, Now got this error
Running composer update to apply merge settings Gathering patches for root package.
DrupalProject\composer\ScriptHandler::checkComposerVersion Loading composer repositories with package information PHP Fatal error: Declaration of React\Promise\RejectedPromise::then(?callable $onFulfilled = null, ?callable $onRejected = null, ?callable $onProgress = null) must be compatible with React\Promise\PromiseInterface::then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null) in /var/www/d9/vendor/react/promise/src/RejectedPromise.php on line 21
Fatal error: Declaration of React\Promise\RejectedPromise::then(?callable $onFulfilled = null, ?callable $onRejected = null, ?callable $onProgress = null) must be compatible with React\Promise\PromiseInterface::then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null) in /var/www/d9/vendor/react/promise/src/RejectedPromise.php on line 21
composer.json as below, few lines are from our repo like patch and contrib_override modules but those can be skipped as problem is not related to those
{
"name": "drupal-composer/drupal-project",
"description": "Project template for Drupal 8 projects with composer",
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "",
"role": ""
}
],
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
},
{
"type": "package",
"package": {
"name": "ckeditor/find",
"version": "4.14.1",
"type": "drupal-library",
"extra": {
"installer-name": "ckeditor/plugins/find"
},
"dist": {
"url": "https://download.ckeditor.com/find/releases/find_4.14.1.zip",
"type": "zip"
}
}
},
{
"type": "package",
"package": {
"name": "ckeditor/liststyle",
"version": "4.8.0",
"type": "drupal-library",
"extra": {
"installer-name": "ckeditor/plugins/liststyle"
},
"dist": {
"url": "https://download.ckeditor.com/liststyle/releases/liststyle_4.8.0.zip",
"type": "zip"
}
}
},
{
"type": "package",
"package": {
"name": "ckeditor/pastefromword",
"version": "4.15.1",
"type": "drupal-library",
"extra": {
"installer-name": "ckeditor/plugins/pastefromword"
},
"dist": {
"url": "https://download.ckeditor.com/pastefromword/releases/pastefromword_4.15.1.zip",
"type": "zip"
}
}
}
],
"require": {
"php": ">=8.0",
"ckeditor/liststyle": "4.8.0",
"ckeditor/pastefromword": "4.15.1",
"composer/installers": "^1.9",
"cweagans/composer-patches": "^1.7",
"drupal/admin_toolbar": "^2.2",
"drupal/allowed_formats": "^1.2",
"drupal/bootstrap_barrio": "^4.24",
"drupal/ckeditor_font": "^1.1",
"drupal/ckeditor_liststyle": "^1.3",
"drupal/conditional_fields": "^1.0@alpha",
"drupal/config_ignore": "^2.2",
"drupal/console": "^1.9.7",
"drupal/core-composer-scaffold": "9.2.18",
"drupal/core-dev": "9.2.18",
"drupal/core-project-message": "9.2.18",
"drupal/core-recommended": "9.2.18",
"drupal/csv_serialization": "^1.4",
"drupal/date_popup_timepicker": "^1.0@alpha",
"drupal/devel": "^4.1",
"drupal/duration_field": "^2.0",
"drupal/entity": "^1.0",
"drupal/eva": "^2.0",
"drupal/field_group": "^3.0",
"drupal/fontawesome": "^2.16",
"drupal/link_iframe_formatter": "1.x-dev",
"drupal/meta_position": "^1.0",
"drupal/optional_end_date": "^1.0",
"drupal/pathauto": "^1.6",
"drupal/s3fs": "^3.0",
"drupal/smtp": "^1.0@RC",
"drupal/twig_tweak": "^2.6",
"drupal/typed_data": "^1.0@beta",
"drupal/ultimate_cron": "^2.0@alpha",
"drupal/upgrade_status": "^3.12",
"drupal/video_embed_field": "^2.4",
"drupal/video_embed_vzaar": "^1.0",
"drupal/view_custom_table": "^1.3",
"drupal/view_unpublished": "^1.0@alpha",
"drupal/views_autocomplete_filters": "^1.3",
"drupal/views_conditional": "^1.0",
"drupal/views_data_export": "^1.0",
"drupal/views_ef_fieldset": "^1.4",
"drupal/weight": "^3.1",
"drupal/workflow": "^1.1",
"drush/drush": "^10.3",
"firebase/php-jwt": "^5.2",
"h4cc/wkhtmltopdf-amd64": "^0.12.4",
"smalot/pdfparser": "^0.16.2",
"vlucas/phpdotenv": "^5.1",
"wa72/htmlpagedom": "1.3.*",
"webflo/drupal-finder": "^1.2",
"wikimedia/composer-merge-plugin": "^2.0",
"zaporylie/composer-drupal-optimizations": "^1.0"
},
"require-dev": {
"phpspec/prophecy-phpunit": "^2",
"phpstan/phpstan": "^1.2"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true,
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"drupal/console-extend-plugin": true,
"cweagans/composer-patches": true,
"drupal/core-composer-scaffold": true,
"drupal/core-project-message": true,
"wikimedia/composer-merge-plugin": true,
"zaporylie/composer-drupal-optimizations": true,
"kylekatarnls/update-helper": true
}
},
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
],
"files": ["load.environment.php"]
},
"scripts": {
"pre-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"post-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
]
},
"extra": {
"composer-exit-on-patch-failure": true,
"patchLevel": {
"drupal/core": "-p2"
},
"drupal-scaffold": {
"locations": {
"web-root": "web/"
}
},
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/contrib/{$name}": ["type:drupal-drush"]
},
"merge-plugin": {
"include": [
"web/modules/contrib_override/*/composer.json",
"web/modules/contrib_override/printable/modules/printable_pdf/composer.json",
"web/modules/custom/*/composer.json"
],
"recurse": true,
"merge-dev": true
},
"enable-patching": true,
"patches": {
"drupal/core" : {
"Core fields delta not consider as change" : "web/patches/core-fields-delta-not-consider-as-change.patch"
}
}
}
}