1

I have Drush 9 installed on Windows 10. I installed it via Composer using Lando.

I want to put this drush in my system path so that I can use it from cmd.exe, Powershell, and so on. I want to do this because I am trying to run Drupal Behat Extension tests with the Drush driver, which requires drush to be in the path.

What I tried

Windows 10 Control Panel -> System -> Edit environment variables

Under "User variables for MYUSERNAME", I added:

  • Variable: LANDO_FRIENDS
  • Value: C:\pathtowebsiteinstalledbycomposer\vendor\bin

Then I rebooted and tried to run drush:

drush : The term 'drush' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

So then, from PowerShell, I changed to the \vendor\bin directory and ran ./drush. This opened up a prompt How do you want to open this file?

I don't understand why this is happening.

Here's what does work:

  • I can run drush from Powershell using lando, i.e., lando drush status.
  • I can open up a bash shell with the Windows Linux Subsystem and go to /vendor/bin and enter ./drush, which causes drush to load normally.

So drush is definitely installed, but how do I use it from Powershell/cmd.exe?

4
  • Can you just add your drush path into PATH system variable?
    – kenorb
    Sep 29, 2017 at 12:11
  • @kenorb It’s in the path (environment variable). Also it’s not even working from Powershell when I try to execute it directly. Sep 29, 2017 at 15:06
  • You're not sharing anything with PATH, can you post the example how your PATH variable looks like?
    – kenorb
    Sep 29, 2017 at 16:10
  • drush is a (Unix) shell script. On Windows you have to run launch drush.bat. Drush expects a couple of tools that normally isn't present on Windows, but feel free to give it a try.
    – hansfn
    Oct 1, 2017 at 6:13

1 Answer 1

1

The variable will be "Path". Just select that one and edit it then add new line.

You have to download the drush.phar file from here: https://github.com/drush-ops/drush-launcher/releases/tag/0.6.0

Then you have to change the file name from 'drush.phar' to just 'drush' and put that file somewhere and that location needs to be in your path. I put mine in both my system path and user path. Once that is done you shoud be able to call drush from your drupal directory if it was installed with composer.

Your Answer

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

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