1

I am trying to setup Drupal 8 on Windows Server 2012 on IIS. I have installed PHP7.0 and Composer. Using Composer I then installed Drush globally using composer global require drush/drush:8.*. Drush was installed at C:\Users\Myusername\AppData\Roaming\Composer\vendor\drush\drush. I have set the Path variable for the user 'Myusername' to include C:\Users\Myusername\AppData\Roaming\Composer\vendor\bin.

The problem I have is that if I cd into the website folder as configured in IIS, and then run drush version, I receive the following error:

"C:\\inetpub\\wwwroot\\mysite\\vendor\\bin\\drush.php.bat" is not recognized as an internal or external command, operable program or batch file.

If I run the same command outside of the site folder as configured in IIS, then drush version executes successfully.

It seems that when run from within the web site folder it is trying to run drush from within the website project instead of using the globally installed drush.

Any suggestions on how to get Drush running for the site?

Updated:

After some experimenting it seems that when I run Drush it looks for the closest vendor\bin directory. If it is not in the current directory, it works its way up the parent directories until it finds it. If it can’t find it, it uses the globally set one. For example, if I run drush from either C:\\inetpub, C:\\inetpub\\wwwroot then will get this error:

`"C:\inetpub\vendor\bin\drush.php.bat" is not recognized as an internal or external command, operable program or batch file.

If I run drush version from outsite of C:\\inetpub directory then it works correctly.

1

Drush Launcher solved the issue for me.

Step 1 Download drush.phar and put it in project root folder

Step 2 Create drush.bat file in project root folder and put following content (it will run phar in window)

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

Now it will use local drush.

  • +1 Running Windows 10 MAMP Drupal installed with composer but Drush would not run. This helped. Thanks, – Dupls Nov 14 '18 at 20:25
0

Your global drush version was not compatible with the site specific drush version or the site specific version of drush was broken. As you indicated, when you run drush version from outside your site the command works but not when the site specific version takes priority.

In my case the global drush version was drush 8.1 and the site specific version was 9.0 beta. To fix the problem I removed the site specific 9.0 beta version and relied on the global version.

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.