Skip to content

Using drush 9 or newer on dropsolid platform

As more and more Drupal modules require Drush 9 or newer for executing tasks, you may have to add it to your project.

The current implementation of Dropsolid Platform has a hard requirement on Drush 8 (and the config and aliases defined as php code/arrays).

The plans are there to move to a less Drush dependent ecosystem, but until then some extra steps are needed to be able to use Drush 9 or newer in your deploy flow

Be aware that Drush 9 is already EOL, and it makes not much sense to install that version. Use Drush 10 instead.

Needed steps

following steps will describe how to add Drush 10 to a Dropsolid Platform Drupal project.

  • Ensure you have no Drush dependency (no 8, 9 or 10) in your root composer.json file. Dropsolid Platform provides a globally installed Drush 8 version (currently 8.3.5)
  • Create a composer_drush10 folder inside project_root/etc with following composer.json file

    {
      "name": "project/composer_drush10",
      "require": {
       "drush/drush": "^10.3",
        "twig/twig": "<<TWIG VERSION>>",
        "guzzlehttp/guzzle": "<<GUZZLE VERSION>>"
      }
    }
    
    • ensure the version of twig and guzzle are the same as in the root composer file. This is necessary to prevent incompatibility issues. You can look up the current version by executing following commands in the root folder: composer show -i twig/twig composer show -i guzzlehttp/guzzle
  • Run composer install to get the Drush 10 and it's dependencies

  • Ensure Drupal can have a separate dependency container for the different Drush versions. Without this change, the site would break when switching between Drush versions or web requests.

    Add following snippet to the settings_<env>.php of all environments.

      /**
      * Deployment identifier.
      *
      * Drupal's dependency injection container will be automatically invalidated and
      * rebuilt when the Drupal core version changes. When updating contributed or
      * custom code that changes the container, changing this identifier will also
      * allow the container to be invalidated as soon as code is deployed.
      */
      $settings['deployment_identifier'] = \Drupal::VERSION;
      // Set a different deployment identifier when using drush on CLI.
      // This supports different drush versions in a non-standard location
      // Otherwise running drush commands from a non-standard location breaks
      // the container for apache or other drush commands.
      if (defined('STDIN') || in_array(PHP_SAPI, ['cli', 'cli-server', 'phpdbg'])) {
        $settings['deployment_identifier'] = Drush::getVersion() . '-' . \Drupal::VERSION;
      }
    

Now you can use Drush 10 in your deploy scripts with following snippet

#!/bin/sh
DRUSH10="$SCRIPT_DIR/../../etc/composer_drush10/vendor/bin/drush"

php ${DRUSH10} <command_you_want_to_execute>