drush-ops / drush-launcher

A small wrapper around Drush for your global $PATH.
GNU General Public License v2.0
237 stars 50 forks source link

Enabling xdebug breaks drush php via the launcher #90

Closed chx closed 3 years ago

chx commented 3 years ago

When launching via the launcher phar, Psy has no prompt and the arrows are broken:

2021-03-25 22_30_32-Window

and @webflo says DRUSH_ALLOW_XDEBUG=1 drush php works and it does so there's something about re-bootstrapping without xdebug here.

leymannx commented 3 years ago

Is it only drush php? All other commands are working? drush cr? Your environment is what exactly? OS? Psyshell version? PHP version? OS version? In what directory are you executing the command?

chx commented 3 years ago

Yes, everything is working. Even drush php itself is working it's just the readline / prompt functionality that's broken. Some terminal issues. I am using the Windows Terminal. I checked and $_SERVER['TERM'] is the same for both launcher and vendor/bin/drush, xterm-256color. It'll be something else... but since Psy\Info() is not working, I have a bit of a hard time figuring out what.

chx commented 3 years ago

I found the launcher adds --ansi to the command but if I manually add it , that doesn't break. I am available for videocalls :)

chx commented 3 years ago

I checked and it finds the drush version in vendor and the backtraces are fundamentally the same. However, $_SERVER is vastly different. While capturing with drush php |tee launcher-drush.txt and vendor/bin/drush php |tee vendor-drush.txt I found I can repro the behavior with the latter command!!

I am reaching the end of my Linux TTY knowledge :/

chx commented 3 years ago

I am closing this as this is not the launcher's fault. I can repro with psysh|tee.

chx commented 3 years ago

Re-closing this and moving on to xdebug-handler.

chx commented 3 years ago

Ha! xdebug-handler already fixed this so this will be solved by https://github.com/drush-ops/drush-launcher/issues/91

bobthecow commented 3 years ago

I am closing this as this is not the launcher's fault. I can repro with psysh|tee.

FWIW this (and the broken xdebug-handler forwarding) is happening because newer versions of PsySH detect when STDIN is not a TTY or when STDOUT is redirected, and act differently.

In the case of xdebug-handler, properly forwarding input and output fixes it. In the case of piping to tee, you'd probably have to override the automatic detection and explicitly set input/output options on PsySH.