8

I've been using drush with xdebug for years. It looks like it broke in the last two weeks, possibly due to modifications made to the core "drush" script (Split 'drush' script into finder, wrapper and launcher stages.). It now dispatches via "pcntl_exec" on Ubuntu, and xdebug never gets control back thereafter.

I've tried reverting drush to the previous commit ("8ab7ad9... Make uli test more resiliant vis-a-vis html tags that may be injected into log messages."), which fixes the xdebug problem, but does not appear to be compatible with RC1 :-(. So I strongly suspect the addition of pcntl_exec.

Anyone know how to get around this, or do I need to log an issue against drush on their github site?

3 Answers 3

7

The former drush script is still available as drush.launcher. I would recommend making this your entrypoint when using Drush with xdebug, and omit the drush "finder" script (called simply "drush") altogether.

If this does not work for you, you should make a report in the Drush issue queue on GitHub.

3
  • Greg -- much thanks. Switching the entry point to drush.launcher indeed fixes the xdebug issue. Commented Oct 13, 2015 at 6:25
  • The 3rd arg of pcntl_exec is $envs, just add XDEBUG_CONFIG there.
    – user49
    Commented Oct 13, 2015 at 10:42
  • 1
    The Drush "finder" script already copies all of the environment variables into $envs, and passes it on the pcntl_exec; I am not sure why this wouldn't work, but since the only purpose of the finder is to select the correct launcher, in a debugging situation it is simpler to just target the launcher, I think. Commented Oct 13, 2015 at 14:55
1

Another option here is to allow a higher number of concurrent debug sessions. Using PHPStorm, where I encountered this same problem, the default is to only allow one connection. If you check in Settings -> Languages & Frameworks -> PHP -> Debug you will find a Max. simultaneous connections setting. Bumping this to 2 or higher will allow the spawned processes to connect with XDebug back to PHPStorm and continue on.

0

I use xdebug with vim using a plugin called vdebug. When debugging drush commands, it would break prematurely in ~/.composer/vendor/drush/drush/drush. To allow xdebug to continue processing when drush executes another script try hitting F7 then F5 in very quick succession.

For more details see the discussion here: https://github.com/joonty/vdebug/issues/97#issuecomment-334481429

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.