I'm not seeing any color output when running drush commands on a remote server (Acquia DevCloud, to be specfic). Anyone know why this might be? I'm happy to dive in, just not sure where to start or if this is a known issue.

Comments

greg.1.anderson’s picture

Look at function _drush_bootstrap_global_options(), and note that color is disabled if $colors = exec('tput colors 2>&1'); does not return an integer >= 3. When you run a remote Drush command, Drush will use ssh to invoke the remote process, which will run without the $TERM environment variable being set. This will cause the remote tput command to return an error; Drush will therefore suppress color output, since it appears to Drush that the current (remote) terminal does not support it.

To fix this, you'd have to modify backend invoke to set an option indicating that color should be used on the remote session, and you'd have to modify _drush_bootstrap_global_options to respect that flag.

patcon’s picture

Thanks so much greg! I'll try to check into this tomorrow.

A quick search seemed to lead me to believe that this might be the key:
http://superuser.com/questions/163167/when-sshing-how-can-i-set-an-envir...
https://github.com/drush-ops/drush/blob/master/examples/example.drushrc....

I'll see if I can get it working through drushrc config before digging into a more long-term solution.

Thanks again!

greg.1.anderson’s picture

With drushrc you could use 'command-specific' to set the 'nocolor' option if you wanted to get rid of color, but unfortunately, Drush does not have a 'color' option. You could set the TERM environment variable as you describe in #2; then you would only need to modify backend invoke. I can't think of any side effects of setting TERM, but there might be some.

Backend invoke is a little hairy...

greg.1.anderson’s picture

Actually, you can use $options['ssh-options'] = ... in drushrc to pass a TERM environment variable to remote calls without modifying backend invoke.

owen barton’s picture

Note that depending on the sshd config the remote server may not allow remote setting of environment variables.

I wonder if simply passing the value of color detection on the "host" system (via a color option, which we would need to add) is the best fix here. I think this should work since everything is encoded (before even being output to the remote terminal) during backend invoke anyway.

greg.1.anderson’s picture

Yeah, that was essentially my advice in #1. The env variable stuff looked like it might be easier, but as you mention, there are potential problems with that approach.

moshe weitzman’s picture

Version: 7.x-5.7 » 8.x-6.x-dev
Category: support » feature
greg.1.anderson’s picture

Status: Active » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.

dannyw99’s picture

Issue summary: View changes

Simply adding this to drushrc allowed me to pass a TERM evar which enabled color for remote drush and also works when called from jenkins, and no need to mess with ssh config:

  '#env-vars'   => array (
        'TERM' => 'ansi'
  ),