New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drush 8 on windows #1696

Closed
MrPhilbert opened this Issue Oct 19, 2015 · 7 comments

Comments

Projects
None yet
5 participants
@MrPhilbert

MrPhilbert commented Oct 19, 2015

The install instructions for drush 8 on windows need corrections.

They say to add the drush/drush folder to your system path. This is not needed as long as drush is installed in the composer/vender bin directory and that directory is in your system path.

Also, when executing the "drush" command from git bash, it will try to open drush.launcher (which windows does not know what to do with). Instead, type drush.php and you'll get access to drush. If you would like to just enter "drush" instead go to you your home directory (user directory) and create or open .bashrc and add "alias drush="drush.php"" without the outside quotes. Next time you open git bash and type drush, all your drush options will be available.

@kenorb

This comment has been minimized.

Show comment
Hide comment
@kenorb

kenorb Oct 20, 2015

Contributor

I can confirm the same issue on Windows 7.

I've added ~/AppData/Roaming/Composer/vendor/bin to my PATH.

  • drush, drush.bat points to drush.launcher (which shows popup: Windows can't open this file)
  • drush.php just points to shell script (which doesn't work in cmd.exe, but works in emulated terminal)

The only binary which works correctly in both (including cmd.exe) is drush.php.bat.

So alias drush=drush.php.bat should work in order to make drush command working.

Related: #1679 (and PR: #1674).

Contributor

kenorb commented Oct 20, 2015

I can confirm the same issue on Windows 7.

I've added ~/AppData/Roaming/Composer/vendor/bin to my PATH.

  • drush, drush.bat points to drush.launcher (which shows popup: Windows can't open this file)
  • drush.php just points to shell script (which doesn't work in cmd.exe, but works in emulated terminal)

The only binary which works correctly in both (including cmd.exe) is drush.php.bat.

So alias drush=drush.php.bat should work in order to make drush command working.

Related: #1679 (and PR: #1674).

@greg-1-anderson

This comment has been minimized.

Show comment
Hide comment
@greg-1-anderson

greg-1-anderson Oct 20, 2015

Member

What is drush.php.bat? Did you mean drush.bat or drush.php or something else?

We do not really sanction calling drush.php directly; while it still has the shebang at the top that makes this possible, we might remove that in #1693 to support a drush phar.

Member

greg-1-anderson commented Oct 20, 2015

What is drush.php.bat? Did you mean drush.bat or drush.php or something else?

We do not really sanction calling drush.php directly; while it still has the shebang at the top that makes this possible, we might remove that in #1693 to support a drush phar.

@kenorb

This comment has been minimized.

Show comment
Hide comment
@kenorb

kenorb Oct 21, 2015

Contributor

I've drush.php.bat and other corresponding batch files for each script, if they're not coming from drush, then maybe there were created by Composer during the install? As I've fairly clean environment.

C:\Users\925309\AppData\Roaming\Composer\vendor\bin>ls -la
total 18
drwxr-xr-x 1 925309 1049089   0 Oct 20 14:45 .
drwxr-xr-x 1 925309 1049089   0 Oct 20 14:01 ..
-rwxr-xr-x 1 925309 1049089 132 Oct 20 13:57 drush
-rw-r--r-- 1 925309 1049089  77 Oct 20 13:57 drush.bat
-rwxr-xr-x 1 925309 1049089 144 Oct 20 13:57 drush.complete.sh
-rw-r--r-- 1 925309 1049089  89 Oct 20 13:57 drush.complete.sh.bat
-rwxr-xr-x 1 925309 1049089 141 Oct 20 13:57 drush.launcher
-rw-r--r-- 1 925309 1049089  85 Oct 20 13:57 drush.launcher.bat
-rwxr-xr-x 1 925309 1049089 136 Oct 20 13:57 drush.php
-rw-r--r-- 1 925309 1049089  81 Oct 20 13:57 drush.php.bat
-rwxr-xr-x 1 925309 1049089 134 Oct 20 13:56 psysh
-rw-r--r-- 1 925309 1049089  79 Oct 20 13:56 psysh.bat

C:\Users\925309\AppData\Roaming\Composer\vendor\bin>type drush.php.bat
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush.php
php "%BIN_TARGET%" %*

After short investigation, seems they were created by Composer:

A .bat file is generated automatically to reference the binary

See: What about Windows and .bat files?

Contributor

kenorb commented Oct 21, 2015

I've drush.php.bat and other corresponding batch files for each script, if they're not coming from drush, then maybe there were created by Composer during the install? As I've fairly clean environment.

C:\Users\925309\AppData\Roaming\Composer\vendor\bin>ls -la
total 18
drwxr-xr-x 1 925309 1049089   0 Oct 20 14:45 .
drwxr-xr-x 1 925309 1049089   0 Oct 20 14:01 ..
-rwxr-xr-x 1 925309 1049089 132 Oct 20 13:57 drush
-rw-r--r-- 1 925309 1049089  77 Oct 20 13:57 drush.bat
-rwxr-xr-x 1 925309 1049089 144 Oct 20 13:57 drush.complete.sh
-rw-r--r-- 1 925309 1049089  89 Oct 20 13:57 drush.complete.sh.bat
-rwxr-xr-x 1 925309 1049089 141 Oct 20 13:57 drush.launcher
-rw-r--r-- 1 925309 1049089  85 Oct 20 13:57 drush.launcher.bat
-rwxr-xr-x 1 925309 1049089 136 Oct 20 13:57 drush.php
-rw-r--r-- 1 925309 1049089  81 Oct 20 13:57 drush.php.bat
-rwxr-xr-x 1 925309 1049089 134 Oct 20 13:56 psysh
-rw-r--r-- 1 925309 1049089  79 Oct 20 13:56 psysh.bat

C:\Users\925309\AppData\Roaming\Composer\vendor\bin>type drush.php.bat
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush.php
php "%BIN_TARGET%" %*

After short investigation, seems they were created by Composer:

A .bat file is generated automatically to reference the binary

See: What about Windows and .bat files?

@kenorb

This comment has been minimized.

Show comment
Hide comment
@kenorb

kenorb Oct 21, 2015

Contributor

The other interesting thing which I've found, that drush.bat which is in bin/ isn't the same as one from Drush package.

925309@UK868678  /c/Users/925309/AppData/Roaming/Composer/vendor
$ find . -name drush.bat -ls
562949953702214    1 -rw-r--r--   1 925309   1049089        77 Oct 20 13:57 ./bin/drush.bat
562949953701942    4 -rw-r--r--   1 925309   1049089       759 Oct 20 13:57 ./drush/drush/drush.bat
562949953702074    1 -rw-r--r--   1 925309   1049089       193 Oct 20 13:57 ./drush/drush/misc/windrush_build/assets/drush.bat

So the original Drush is in ./drush/drush/drush.bat, and ./bin/drush.bat is the Composer one (which is the wrapper to drush script)

$ cat $(where drush.bat)
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush
php "%BIN_TARGET%" %*

Not sure if this is expected install behavior as I'm a bit confused. Actually most of the scripts in bin/ are Composer wrappers as shown below:

925309@UK868678  /c/Users/925309/AppData/Roaming/Composer/vendor/bin
$ head -n3 *
==> drush <==
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"

==> drush.bat <==
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush
php "%BIN_TARGET%" %*

==> drush.complete.sh <==
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"

==> drush.complete.sh.bat <==
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush.complete.sh
php "%BIN_TARGET%" %*

==> drush.launcher <==
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"

==> drush.launcher.bat <==
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush.launcher
sh "%BIN_TARGET%" %*

==> drush.php <==
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"

==> drush.php.bat <==
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush.php
php "%BIN_TARGET%" %*

==> psysh <==
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"

==> psysh.bat <==
@ECHO OFF
SET BIN_TARGET=%~dp0/../psy/psysh/bin/psysh
php "%BIN_TARGET%" %*

Btw. Running drush.launcher.bat works correctly in cmd, PS and ConEmu, calling drush.launcher works in PS and ConEmu, but not in standard cmd.

Running drush it-self generates popup error (can't open) in all shells (cmd, PS & ConEmu).

Related:

Contributor

kenorb commented Oct 21, 2015

The other interesting thing which I've found, that drush.bat which is in bin/ isn't the same as one from Drush package.

925309@UK868678  /c/Users/925309/AppData/Roaming/Composer/vendor
$ find . -name drush.bat -ls
562949953702214    1 -rw-r--r--   1 925309   1049089        77 Oct 20 13:57 ./bin/drush.bat
562949953701942    4 -rw-r--r--   1 925309   1049089       759 Oct 20 13:57 ./drush/drush/drush.bat
562949953702074    1 -rw-r--r--   1 925309   1049089       193 Oct 20 13:57 ./drush/drush/misc/windrush_build/assets/drush.bat

So the original Drush is in ./drush/drush/drush.bat, and ./bin/drush.bat is the Composer one (which is the wrapper to drush script)

$ cat $(where drush.bat)
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush
php "%BIN_TARGET%" %*

Not sure if this is expected install behavior as I'm a bit confused. Actually most of the scripts in bin/ are Composer wrappers as shown below:

925309@UK868678  /c/Users/925309/AppData/Roaming/Composer/vendor/bin
$ head -n3 *
==> drush <==
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"

==> drush.bat <==
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush
php "%BIN_TARGET%" %*

==> drush.complete.sh <==
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"

==> drush.complete.sh.bat <==
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush.complete.sh
php "%BIN_TARGET%" %*

==> drush.launcher <==
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"

==> drush.launcher.bat <==
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush.launcher
sh "%BIN_TARGET%" %*

==> drush.php <==
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"

==> drush.php.bat <==
@ECHO OFF
SET BIN_TARGET=%~dp0/../drush/drush/drush.php
php "%BIN_TARGET%" %*

==> psysh <==
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"

==> psysh.bat <==
@ECHO OFF
SET BIN_TARGET=%~dp0/../psy/psysh/bin/psysh
php "%BIN_TARGET%" %*

Btw. Running drush.launcher.bat works correctly in cmd, PS and ConEmu, calling drush.launcher works in PS and ConEmu, but not in standard cmd.

Running drush it-self generates popup error (can't open) in all shells (cmd, PS & ConEmu).

Related:

@weitzman

This comment has been minimized.

Show comment
Hide comment
@weitzman

weitzman Nov 10, 2015

Member

The install instructions now recommend using drush.phar which avoids composer entirely. Well Windows users first are discouraged from using Windows but then they could use drush.phar. See http://docs.drush.org/en/master/install-alternative/#windows - suggestions welcome.

Member

weitzman commented Nov 10, 2015

The install instructions now recommend using drush.phar which avoids composer entirely. Well Windows users first are discouraged from using Windows but then they could use drush.phar. See http://docs.drush.org/en/master/install-alternative/#windows - suggestions welcome.

@weitzman weitzman closed this Nov 10, 2015

@weitzman

This comment has been minimized.

Show comment
Hide comment
@weitzman

weitzman Nov 10, 2015

Member

Woops - reopening for feedback.

Member

weitzman commented Nov 10, 2015

Woops - reopening for feedback.

@ivanjaros

This comment has been minimized.

Show comment
Hide comment
@ivanjaros

ivanjaros Dec 3, 2015

I am using composer as well. No point in fiddling with phar.
Also in Windows drush will throw 'site' error on D7 site when running updb at this moment(8.0.1).

ivanjaros commented Dec 3, 2015

I am using composer as well. No point in fiddling with phar.
Also in Windows drush will throw 'site' error on D7 site when running updb at this moment(8.0.1).

@weitzman weitzman closed this Dec 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment