drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.34k stars 1.08k forks source link

Drush hangs when accessing remote with `drush @alias status` #4199

Open laradevitt opened 5 years ago

laradevitt commented 5 years ago

Describe the bug

I suspect this is Windows-related.

When I try to execute drush @alias status on a remote (Linux) server from my local (Windows) machine the output isn't written to terminal. It just hangs. However copying the executed ssh command directly into the CLI works fine.

To Reproduce

drush/sites/self.site.yml

prod:
  host: d8.example.com
  user: drupal
  root: /home/drupal/d8/web
  uri: http://d8.example.com
  os: Linux
  ssh:
    options: '-vvv -E log.txt'
    tty: false
local:
  uri: http://d8-local.example.com
  os: Windows

drush/drush.yml

# Because why not?
options:
  ssh:
    tty: false

Run with drush:

$ drush @prod status -v

Expected behavior

  1. Receive SSH passphrase prompt
  2. Enter passphrase
  3. Status output written to terminal.

Actual behavior

  1. OpenSSH passphrase dialog opens
  2. Enter passphrase
  3. CLI hangs. No status output, just:
[info] Executing: ssh -vvv -E log.txt drupal@d8.example.com 'drush status -v --uri=http://d8.example.com --root=/home/drupal/d8/web'

log.txt looks good, except for these two lines:

debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: permanently_drop_suid: 197609

Workaround

Not really a workaround, but if I copy and paste the ssh command directly, it works fine:

$ ssh -vvv -E log.txt drupal@d8.example.com 'drush status -v --uri=http://d8.example.com --root=/home/drupal/d8/web'

Output:

Enter passphrase for key '/c/Users/user/.ssh/id_rsa':
 Drupal version   : 8.7.7
 Site URI         : http://d8.example.com
 DB driver        : mysql
 DB hostname      : localhost
 DB port          :
 DB username      : drupal
 DB name          : drupal8
 Database         : Connected
 Drupal bootstrap : Successful
 Default theme    : bartik
 Admin theme      : seven
 PHP binary       : /usr/bin/php7.2
 PHP config       : /etc/php/7.2/cli/php.ini
 PHP OS           : Linux
 Drush script     : /usr/local/bin/drush
 Drush version    : 9.7.1
 Drush temp       : /tmp
 Drush configs    : /home/drupal/d8/vendor/drush/drush/drush.yml
                    /home/drupal/d8/drush/drush.yml
 Install profile  : standard
 Drupal root      : /home/drupal/d8/web
 Site path        : sites/default
 Files, Public    : sites/default/files
 Files, Temp      : /home/drupal/tmp

log.txt is the same except it does not contain the two lines indicated above.

System Configuration

(local)

Q A
Drush version? 10.0.0-dev
Drupal version? 8.7.7
PHP version 7.2.x
OS? Windows

OpenSSH_7.3p1, OpenSSL 1.0.2k 26 Jan 2017

Additional information

Thanks!

johnpitcairn commented 4 years ago

Similar problem here. Directing output to a text file does not work, the trxtfile is created but nothing is written.

greg-1-anderson commented 4 years ago

None of the Drush maintainers use Windows. We need help from the community to get site process working correctly cross-platform. PRs welcome in the site process repository.

johnpitcairn commented 4 years ago

Thanks and understood. I'm troubleshooting for a new Drupal user on Windows, so I'm unlikely to invest dev time for Windows. We do intend to try WSL next, rather than his current Xammp and git-bash setup.

Ambient-Impact commented 4 years ago

I'm on Windows and ran across this same issue just the other day. I'm interested in attempting to track this issue down, but I don't have much experience with the Drush codebase outside of writing a few Drush 9+ commands. Should I open an issue in the site process repository and ask for guidance there?

weitzman commented 4 years ago

You are welcome to do that, but as stated above it wont be the maintainers of the project that immediately answer.

Ambient-Impact commented 4 years ago

To clarify: I'm referring to the general structure of the Drush codebase and where to find things/what the execution path is for various things - i.e. the platform-independent PHP, which I assume all the maintainers are familiar with, regardless of platform?

Ambient-Impact commented 4 years ago

After several hours of digging and inspecting various things, I've only learned a few things, including the hilarious number of workarounds the Symfony Process component has to do on Windows. There are some details to be found in https://github.com/symfony/symfony/issues/14252.

Some findings:

It's hard to say if this is entirely a Drush bug, but since the above seem to work correctly, it's looking more that way.

greg-1-anderson commented 4 years ago

It would be interesting to see the exact code that you used to successfully run a Symfony\Process command on Windows. Note that there are multiple different modes that you need to worry about; for example, if you run in tty mode you will be able to do things like run vi, but won't be able to capture output in the calling script. Site Process usually runs in non-interactive mode so that it can capture the output. Both modes are important to support, though.

Ambient-Impact commented 4 years ago

I included the exact script in the Site Process issue I opened and referenced above, and included a bunch more findings. As for TTY: apparently Symfony\Process doesn't support it at all on Windows.

greg-1-anderson commented 4 years ago

Ah, missed that. Commented on the other issue.