The latest Drush 9.x version recommends that Drupal 8 sites will be built using Composer, with Drush listed as a dependency. However, when you install Composer and Drush globally per step #1 on http://docs.drush.org/en/master/install and then proceed to step #2 Installing Drush Launcher and then try to run Drush on a pre-existing Drupal website (e.g. drush --version), then you will get:

Drush Launcher Version: 0.6.0
The Drush launcher could not find a Drupal site to operate on. Please do one of the following:

  • Navigate to any where within your Drupal project and try again.
  • Add --root=/path/to/drupal so Drush knows where your site is located.

How do I get around this problem, and make Drush work with pre-existing Drupal sites?

2 Answers 2

  • Should I create a new empty git repository before I migrate an existing Drupl 8 site, or should I initialize the git repository with the drupal-composer/drupal-project:8.x-dev template first and then overwrite the web directory?
    – lanoxx
    Mar 11, 2019 at 7:30

In case you use Drupal7, I did

drush pm-list --status="enabled" --no-core --fields=name,version > modules.txt
while read line; do comp=`echo $line | sed 's/.*(\(.*\))/\1/' - | sed 's/7\.x\-//' - | awk '$1=$1'`; echo \"drupal\/`echo $comp | awk '{ print $1 }'`\"\:\ \"`echo $comp | awk '{ print $2 }'`\"; done < modules.txt

You can cut&paste your modules list directly into your composer :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.