Upgrading a Drupal site to a new major version can be challenging, especially when key modules are not yet officially compatible. One common scenario is when a module has a pending merge request (MR) with a fix, but the official release hasn't been updated.
This was the case when I upgraded my blog to Drupal 11 and encountered an issue with the Disqus module, which was not yet ready for Drupal 11. However, a fork with a compatible branch existed.
In this article, I'll walk you through how to install a Drupal module from a forked repository and a specific branch using Composer. This method is useful for applying fixes or using unofficial patches while waiting for an official release.
Steps to Install a Drupal Module from a Forked Repository
1. Identify the Fork and Compatible Branch
The first step is to find the fork that contains the necessary changes. In my case, I found an issue with a merge request on Drupal.org that contained a fork with a branch for Drupal 11 compatibility.
Example Forked Repository:
- Fork URL: https://git.drupalcode.org/issue/disqus-3296968/-/tree/3296968-d11
- Branch: 3296968-d11

2. Modify the composer.json File
Steps:
- Open your composer.json file.
Add the following entry under the repositories section:
"repositories": [ { "type": "git", "url": "https://git.drupalcode.org/issue/disqus-3296968.git" } ]and add this to the first repository with url : "https://packages.drupal.org/8"
"exclude": [ "drupal/disqus" ]Then, require the module with the specific branch using Composer:
composer require "drupal/disqus:dev-3296968-d11"The version now is dev-[branche-name] not 2.0.1 for example.
3. Verify the Installation
Once the module is installed successfully, verify that it appears in your Drupal site's module list:
drush pm:list | grep disqusThen, enable the module if needed:
drush en disqus -yConclusion
Installing a Drupal module from a fork is a useful technique when an official release is not yet available for a new Drupal version. By modifying composer.json to point to a forked repository and a specific branch, you can apply community fixes and continue your Drupal upgrade process without waiting for the official release.
This method ensures your site stays up-to-date while leveraging community contributions. However, once the official module is updated, it's a good practice to switch back to the stable release by running:
composer require drupal/disqusThis guide applies not only to the Disqus module but also to any Drupal module with pending updates in a forked repository.
Happy upgrading 😎!