2

I ran composer global require drush/drush:8.1.3 and added C:/Users/username/AppData/Roaming/Composer/vendor/drush/drush to the value of the PATH variable.

drush status returns the following output.

 PHP configuration      :  C:\xampp\php\php.ini
 PHP OS                 :  WINNT
 Drush script           :  C:\Users\username\AppData\Roaming\Composer\vendor\dr
                           ush\drush\drush
 Drush version          :  8.1.3
 Drush temp directory   :  C:\Users\username\AppData\Local\Temp
 Drush configuration    :
 Drush alias files      :

When I change directory to the one containing the Drupal files, and I run drush status, I get this error.

'C:\xampp\htdocs\drupal-project\drush' is not recognized as an internal or external command,operable program or batch file.

Why?

1

There are many things to comment here: Why are you installing Drush 8 and why the specific (outdated) version 8.1.3?

What happens is that your global Drush looks for a site local Drush, finds something ("C:\xampp\htdocs\drupal-project\drush") and tries to execute it.

The recommended approach - at least if you have a site local Drush, which you have if you installed Drupal using Composer and "drupal-composer/drupal-project" - is to use Drush Launcher (instead of a global Drush). NB! Read this issue so it works smoothly on Windows.

After you have fixed the path so Drush Launcher is used instead of the global Drush, try drush status again. I expect it to find the correct site local Drush. You migh also want to try drush --versionto verify which version of the launcher and Drush itself that is used.

You can test that the setup is correct by running Drush inside the directory containing Drupal:

1) If you have installed Drush Launcher correct, you should get the following output:

# drush --version
Drush Launcher Version: 0.6.0
Drush Commandline Tool 9.2.3

2) If you however have installed a global Drush 9 (using Compser) in stead of Drush Launcher, you get the following output:

# drush --version
'PATH_TO_DRUPAL_PROJECT/vendor/drush/drush/drush' is not recognized as an internal 
or external command, operable program or batch file.
  • I need Drush 8 because use Drupal 8. I checked the issue but I don't have drush.phar file on my machine. I installed Drush with composer so when should add this lines @echo off php %~dp0\drush.phar %* – user3421014 Apr 5 '18 at 12:32
  • 1
    Please read the Drush Launcher page I linked to - before reading the issue. There is a paragraph about installation ... Drush 9 works nicely with current versions of Drupal. Anyway, the important thing was that you chose to install 8.1.3 when the current version is 8.1.16 or something. Why? – hansfn Apr 5 '18 at 16:01
  • I updated the Drush and now drush status returns the following output PHP binary : C:\xampp\php\php.exe PHP config : C:\xampp\php\php.ini PHP OS : WINNT Drush script : C:/Users/username/AppData/Roaming/Composer/vendor/drush/drush/drush Drush version : 9.3-dev-g94f9a72e Drush temp : C:\Users\username\AppData\Local\Temp Drush configs : C:\Users\username\AppData\Roaming\Composer\vendor\drush\drush/drush.yml but in the project 'C:\xampp\htdocs\drupal-project/vendor/drush/drush/drush' is not recognized as an internal or external command Please help. – user3421014 Apr 6 '18 at 8:26
  • 1
    Please, please follow my advice. I said that you should install Drupal Launcher and make sure Drush Launcher is used instead of the global Drush. Updating the the global Drush isn't correct. I just tested, and if I install a global Drush I get the exact same error as you. There is a reason they have developed the Drush Launcher ... I'll update my reply with expect output. – hansfn Apr 6 '18 at 12:04
  • You don't necessarily need to have the project to be setup with Composer. All you need is a configured core installer-path and drush/drush: github.com/drush-ops/drush-launcher/issues/… – So that makes it very easy to use with older Drupals as well. – leymannx Apr 6 '18 at 14:52

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.