Just did a manual upgrade from windows installer 5.8 to 6.0-dev in order to create a patch.

After cloning the latest repository to the emptied original drush directory, I went to my GitBash shell as usual and typed "drush st"
got an error with drush status:

$ drush st
ERROR: can't find php.

No drush commands would work ~ in any directory.

I compared old and new drush directories and files. The new version added a classes directory with one file (DrushRole.php).

I did notice that a file called simply 'drush' in main directory was a different size and compared them. It seemed this was an important file, so I swapped the new with the old.

The errors went away. However, I went back to the new version of the file and tried running drush in a normal Windows command prompt instead of my usual MINGW32 Git Bash shell and it ran fine. So the problem might be with the "drush" file and what it is doing to determine the path to PHP with regard to the Git Bash shell that is download with Msysgit window installer.

I like the Git Bash shell better than the windows command prompt or Power Shell because aliases are so much easier and I get a lot of command that aren't allowed in Windows command line.

Comments

greg.1.anderson’s picture

All three shells are supported, but the Git Bash / MinGW shell is preferred. None of the Drush maintainers use Windows, so it would be really useful if you could help out here.

The first step is to track down the commit that broke the drush script. You can read up on the 'git bisect' command for a really slick way to do that. If you don't want to learn git bisect, you can also try looking at the output of git annotate drush, which will show you which commit most recently changed each line of the file drush.

Here's one example that looks suspcious:

3b0da4e2	(     ghoti	2013-03-11 16:23:23 -0700	61)  php="$(which php-cli php 2>/dev/null | head -1)"

The first number is the commit hash. From the commit hash we can find the commit comment with git log:

$ git log --oneline 3b0da4e2 | head -n 1
3b0da4e Issue #1939982 by ghoti: drush launcher reports `php-cli: not found` by default

You can try backing out the patch applied from #1939982: drush launcher reports `php-cli: not found` by default, or use git to remove the commit via the commit hash, like so:

$ git checkout -b drush-windows
$ git revert 3b0da4e2

You can test from there and see if that has any affect on the observed behavior. To get rid of your working branch:

$ git checkout 8.x-6.x
$ git branch -D drush-windows
JSCSJSCS’s picture

Excellent choice. I did the git bisect and tested each bisection until it came up with the very commit you suggested.
Reverting cleared the issue.

I don't understand the code, but clearly the patch removed php="`which php`" in favor of php="$(which php-cli php 2>/dev/null | head -1)"

"which php" is a command that works in MingGW and resolves to /c/wamp/bin/php/php5.3.10/php

As far as I can determine, windows (and WAMP) does not have php-cli per se. it uses php -f to do that sort of thing, so "which php-cli" does not return anything in Windows (WAMP).

Apparently the patch in question solves an issue for FreeBSD, but creates and issue for WAMP and MinGW. I don't know enough to suggest a fix for us Windows people.

greg.1.anderson’s picture

Status: Active » Fixed

I shouldn't have committed that patch. The pattern $(which ... ) is more readable than `which ...`, but we avoid using it in the drush script because the later construct works in more environments.

The other problem with that patch is that it reports that it fails with "can't find php" before it does the special check for MSYSGIT. The order of the code I committed is a little different than previously used; going with the comment, I test for MSYSGIT before trying `which php`.

I committed the fix to the latest 8.x-6.x and 7.x-5.x (see: f79a3be. Please give it a try, and re-open if there are still problems.

JSCSJSCS’s picture

I want to start out by saying "THANKS ~ IT WORKED!" on my local machine. But I had to do some tweaking to get 6.0 to work on the Dreamhost remote...(not Drush's fault)

I updated my local environment to the newest drush 8.x-6.x and it fixed my issue with MinGW on the local, but when I updated the remote (dreamhost) to 8.x-6.x and connected with putty, it coughed at it:

[okul]$ drush st
Your command line PHP installation is too old. Drush requires at least PHP 5.3.5. [error]

I did not change my remote's .bash_profile which contains:

alias drush='/usr/local/php5/bin/php ~/drush/drush.php --php=/usr/local/php5/bin/php'

or my .bashrc remote file which has always been commented out of all lines.

I just renamed the original drush (5.8) remote directory before cloning the latest drush; restarted putty and got the error above.
After renaming the new drush directory to drush6 and renaming the old drush back and re-starting putty, everything worked again.

On a whim, I tried changing the remote .bash_profile line to just:

alias drush='/usr/local/php5/bin/php ~/drush/drush.php'

but after restarting putty, that did not help. Removing the line entirely got me:
-bash: drush: command not found

Okay, so maybe i have the wrong php verison? I run php -v and get:

[okul]$ php -v
PHP 5.2.17 (cli) (built: Mar 1 2012 16:44:05)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

I need a newer version of PHP for Drush 6.0-dev to run in!

Again, on a whim, I changed my remote .bash_profile alias to:

alias drush='/usr/local/php53/bin/php ~/drush/drush.php --php=/usr/local/php53/bin/php'

Even thought my domains are all set to PHP 5.3 in the Dreamhost control panel, the putty session for my home user directory reports 5.2.17, but "drush st" on 8.x-6.x is working now and reports:

PHP configuration : /etc/php53/php.ini
Drush version : 6.0-dev

I know this is a bit long winded, but I wanted others who may experience this issue in the future to know what I did to resolve it.

greg.1.anderson’s picture

Yes, that last part in #4 is correct, but discouraged. It is preferable to use the 'drush' script, and set DRUSH_PHP to indicate which php Drush should use.

Something like this:

export DRUSH_PHP=/usr/local/php53/bin/php
alias drush=~/drush/drush

In any event, glad to hear it's working for you.

JSCSJSCS’s picture

Status: Fixed » Active

Greg,

I modified the remote's .bash_profile to your suggested changes and everything still worked correctly. Thanks for that.

I was wondering, now that I have upgraded to 8.x-6.x, when I run 'drush @mdj.prod st' from my local environment, I get:

$ drush @mdj.prod st
Your command line PHP installation is too old. Drush requires at least PHP 5.3.5.     [error]

But my Windows (WAMP) environment is running a required version:

$ which php
/c/wamp/bin/php/php5.3.10/php

Any idea what file and changes I need to change so my local Git Bash drush 6.0-dev will be able to get status on the remote again as 5.8 did?

JSCSJSCS’s picture

Status: Active » Closed (works as designed)

I think I found it...at least the drush status for remotes is working now. Not drush's fault.

I had to add the following to my alias(es) files for my remote aliases:

  'php' => '/usr/local/php53/bin/php',  

I read in the example.aliases.drushrc.php file that:

* - 'php': path to custom php interpreter, defaults to /usr/bin/php

My guess is that my host (dremahost) has a php interpreter at '/usr/bin/php' (probably 5.2.17) and it did work with 5.8, but since drush 6.0-dev requires php 5.3, I got the error.

brycefisherfleig’s picture

Has this patch from #3 been incorporated into the latest windows installer? I can never seem to get Drush working on windows without using the installer.