Drush 9, PTY allocation request failed on channel 0

Problem

After updating my local Drush and converting an alias for a Pantheon site, I was getting no output except the error

PTY allocation request failed on channel 0

Solution

Using --debug, I found that drush is calling ssh with the -t option:

$ drush @example.dev status --debug
 [preflight] Config paths: /Users/********/.drush/drush.yml,/Users/********/.composer/vendor/drush/drush/drush.yml
 [preflight] Alias paths: /Users/********/.drush/sites,/etc/drush/sites,/Users/********/.composer/vendor/drush/drush/drush/sites
 [preflight] Commandfile search paths: /Users/********/.composer/vendor/drush/drush/src
 [debug] Redispatch hook status [0.11 sec, 7.11 MB]
 [command] Backend invoke: ssh -p 2222 -o "AddressFamily inet" -t *****************@appserver.*****************.drush.in 'drush  --verbose --debug --uri=https://example.com  status -vvv 2>&1' 2>&1 [0.11 sec, 7.12 MB]
Calling proc_open(ssh -p 2222 -o "AddressFamily inet" -t *****************@appserver.*****************.drush.in 'drush  --verbose --debug --uri=https://example.com  status -vvv 2>&1' 2>&1);
PTY allocation request failed on channel 0
 [debug] Redispatch hook exit early [1.97 sec, 7.12 MB]

A grep in the drush code found the tty option for drush alias declarations:

# - 'ssh': Contains settings used to control how ssh commands are generated
#   when running remote commands.
#   - 'options': Contains additional commandline options for the ssh command
#   itself, e.g. "-p 100"
#   - 'tty': Usually, Drush will decide whether or not to create a tty (via
#   the ssh '--t' option) based on whether the local Drush command is running
#   interactively or not. To force Drush to always or never create a tty,
#   set the 'ssh.tty' option to 'true' or 'false', respectively.

Sure enough, adding tty: False to the ssh options in the alias declaration made the error go away, and drush worked as expected:

  ssh:
    options: '-p 2222 -o "AddressFamily inet"'
    tty: False

 

Add new comment