rfay
rfay

Reputation: 12975

How can I use drush 8 with Drupal 8 or Drupal 9?

I am upgrading a site and don't want to site-install (composer-install) drush at all, but I need it. I know that on my Drupal 7 project drush8 is installed, but I'd like to use it in my Drupal8+ project as well, without changing the project.

Upvotes: 0

Views: 545

Answers (1)

rfay
rfay

Reputation: 12975

drush8 is installed in the web container as /usr/local/bin/drush8, but on Drupal8+ it's not linked to drush because the recommended technique is to site-install it (ddev composer require drush/drush) but you can just symlink drush8 to /usr/local/bin/drush and you'll immediately have ddev drush working with drush 8.

There are two ways to do this:

  1. Use a custom .ddev/web-build/Dockerfile:
ARG BASE_IMAGE
FROM $BASE_IMAGE
RUN ln -s /usr/local/bin/drush8 /usr/local/bin/drush
  1. Use a post-start hook to do the linking. Add this to your .ddev/config.yaml:
hooks:
  post-start:
  - exec: ln -s /usr/local/bin/drush8 /usr/local/bin/drush

The first way (Dockerfile) is probably better because it only happens once, whereas the second way (config.yaml post-start) happens every time you do a ddev start.

Note that if you just want to use a site-installed drush that is in a nonstandard location, you can do that using the similar recipe at https://stackoverflow.com/a/69399975/215713

Upvotes: 2

Related Questions