I've been trying to set up a debug environment for Drush using Eclipse(Kepler), in order to find out why the difference of the result of running hook_install() between via Web UI and via "Drush en". My LAMP stack is ZendServer(6.0.1), and I am using ZendDebugger. So far it works fine for Drupal debugging.
I followed this post: http://blokspeed.net/blog/2012/04/debugging-drush-with-eclipse-and-xdebug/ to begin the setup. The Eclipse prompts for the root folder for Drush to run and it seems to be picked-up by Drush, but on console Drush still complains that it needs a higher bootstrap level to run:
Command pm-enable needs a higher bootstrap level to run - you will [error] need to invoke drush from a more functional Drupal environment to run this command. [0.58 sec, 12.04 MB] The directory [error] /Users/r8d/dev/git/drupal/sites/10088.localhost does not contain a valid Drupal installation [0.59 sec, 12.04 MB]
Where /Users/r8d/dev/git/drupal is the Document root of this Drupal site and the settings.php is indeed located within sites/10088.localhost.
I compared the $_SERVER variables and have found these values are different from running Drush directly from command-line in the 10088.localhost folder:
Array ( ... [SCRIPT_FILENAME] => /usr/local/zend/share/pear/drush/drush.php [SCRIPT_NAME] => /index.php [PWD] => /Users/r8d/dev/git/drupal/sites/10088.localhost … )
The index.php is where the Drupal bootstrap starts.
But, in Eclipse:
Array ( ... [SCRIPT_FILENAME] => /usr/local/zend/share/pear/drush/drush.php [SCRIPT_NAME] => /usr/local/zend/share/pear/drush/drush.php [PWD] => /usr/local/zend/share/pear/drush … )
I then tried to make an Environment variable PWD in the debug setting to hopefully override $_SERVER['PWD'] but in vein.
The debugging does work for Drush itself, though. I can step within Drush till it ends with error. Just that, although Drush does pick up the --root argument, hence the error message, it seems not seeing settings.php, which is vital in order to debug the hook_install() in the Drupal site.
Besides all these findings, I also find PHP executable also matters. I use the php executable that comes with ZendServer at /usr/local/zend/bin/php, with /usr/local/zend/etc/php.ini and SAPI Type set to CLI. If I switch to /usr/local/zend/bin/php-cli the drush command will run like no argument is taken, although it uses the same php.ini.
Is there anything I am missing? What should I do to get the drush debuggin work? I am meanwhile still digging the difference of environment settings with Eclipse. Thanks in advance for those who try to understand the situation and give advices!