How to install Drupal distribution when patches fail

Installing a Drupal distribution is not always smooth sailing. In some cases, a core or module patch can prevent you from properly installing the distribution.

That usually happens when the patches no longer cleanly apply and distribution's composer.json is configured to exit on patch failure. Check the composer.json file and look for this line:

"composer-exit-on-patch-failure": true

Setting this value to true is a double-edged sword for developers. On one hand, this is usually a good idea because distribution needs all the patches to be applied to work properly.

On the other hand, developers have to closely monitor patched modules and update composer.json if a patch gets applied or no longer applies because of some code changes.

For example, at the moment it's not possible to install EzContent distribution. If you try to install it with Composer:

composer create-project srijanone/ezcontent-project:^1.0 MY_PROJECT --no-interaction

 you will see this error:

Image

As you can see the installation process exits because the distribution author's configured Composer to exit on patch failure.

And patching fails because the Moderation Dashboard module has a new release with patch #3048782 applied. Until EzContent developers remove the patch from composer.json you will see this error.

What can you do in this case?

Go to the directory where you tried to install the distribution and delete everything but the composer.json file. Open the file and change composer-exit-on-patch-failure to false. Then run:

composer install

The installation process should now run smoothly again and without issues.

Image

As soon as there is a new release of the distribution update composer.json and revert the composer-exit-on-patch-failure setting to true. In the long term, you don't want to keep this setting to false because it can lead to unpredictable issues and instability.

About the Author

Goran Nikolovski is a web and AI developer with over 10 years of expertise in PHP, Drupal, Python, JavaScript, React, and React Native. He founded this website and enjoys sharing his knowledge.