2

When I run Drush in the command line on my Windows 10 computer or Windows Server 2016 servers, I get the following error:

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.
At line:1 char:1
+ drush
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (drush:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I've downloaded drush launcher and made sure that it was located in my PATH. Why is this error message showing and how do I get passed it?

2

The error message occurs because the command must be drush.phar and prefaced by the php command. In the same folder as Drush Launcher, you'd have to run php drush.phar to get it to work. Elsewhere, you'd have to run php /path/to/drush.phar (which can be just as, if not more, annoying that vendor/bin/drush).

To get it to work, create a folder called drush.bat in the same folder as drush.phar and include the following two lines of code:

@echo off
php %~dp0\drush.phar %*

This file is executed by the command drush since it is in your PATH and will then execute the proper php command passing the correct parameters. You'll then be able to run drush from anywhere on your computer.

0

Did you change the file name of drush.phar to just drush? After that put it in your path.

I just got it working for me on windows 10. I downloaded drush.phar from: https://github.com/drush-ops/drush-launcher/releases/tag/0.6.0

Then I changed the name of the file to just drush and put it in my system and user path and now I can call drush from composer built drupal site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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