[SOLVED] How to install v8 only contrib module with v9 patch

Zyxware default image3

Actually, we can't install an incompatible module with the composer and apply a compatibility patch afterward. However, since issue forks are branches it's possible to install the module using that branch. 

Under the repositories section where the composer source is listed, we need to add an exclude key for our module that we're trying to install using the issue fork. In the following example trying to install an issue for the homebox module.

Complete repositories key look like  this now:

"repositories": [
        "type": "composer",
        "url": "https://packages.drupal.org/8",
        "exclude": [
        "type": "git",
        "url": "[email protected]:issue/homebox-3146462.git"

The next step we need to do for this is to use the composer install command to require the module. Important here is that you need to specify the branch name prefixed with "dev-". We can use the following command for that.

composer require 'drupal/homebox:dev-3146462-drupal-9-compatibility'

It's possible that for the first time when you execute this you're prompted to allow the ECDSA key fingerprint for git.drupal.org. Just type yes and the composer will continue.