Drupal 9 and Drush 10

Drupal 9 and Drush 10

Composer is a great tool for Drupal and in general PHP developers, but in some cases, it might take some effort to accomplish what you want. I tried to install Drupal 9 (dev version) and Drush 10 today and here's what I had to do to make it work.

I'm using Docker4Drupal for my local environment, so the first step was to configure a new project according to the documentation. After that, I just cloned Drupal 9 using GIT and executed composer install. Starting with Drupal 8.8, we have the template projects provided directly by Drupal core so we don't have to use drupal-composer/drupal-project anymore.

Now the fun part. To install Drush 10 in theory you just have to execute:

composer require drush/drush:^10

But if you do that you will see the following error:

Drupal 9 and Drush 10 Composer error
Drupal 9 and Drush 10 Composer error

That looks scary!

Fortunately, fixing it is easy. This is happening because of symfony/var-dumper component. Drupal 9 has the following constraint: 

"symfony/var-dumper": "^4.3|^5.0"

while Drush 10 has this one:

"symfony/var-dumper": "^3.4 || ^4.0",

Running composer install after you clone Drupal core will install version v5.0.0 of symfony/var-dumper. That's not good because Drush is not supporting that version.

The fix is to find the common ground and add the following line to the composer.json file:

"symfony/var-dumper": "^4.4"

Version 4.x is supported by both Drupal 9 and Drush 10, so you will now be able to install the latest version of Drush. After adding this line first downgrade var-dumper and then install Drush:

composer update symfony/var-dumper
composer require drush/drush:^10

Yay!

Drupal 9 and Drush 10 Composer success
Drupal 9 and Drush 10 Composer success

Note: This will probably be fixed soon by Drush using the same versions of symfony/var-dumper as Drupal, but let this blog post be of educational value.

***

You can also read my blog post on how to make your site Drupal 9 ready.

If I can be of assistance, please do not hesitate to contact me.

About the author

Goran Nikolovski is a highly experienced Drupal developer with an extensive skill set that includes PHP, MySQL, HTML, CSS and Javascript. He has experience with large Drupal sites and Drupal Commerce 2.x integration, and he is author of several Drupal modules.