New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output from Colorize Ruby gem doesn't appear colorized #5
Comments
Do you get other color output? For example from bundle install? Cause this looks like standard ANSI color scheme as far as I can see. |
Hi @dblock, Here's a way to reproduce the bug. If you have Ruby installed, please try this from the command line:
Both lines should appear red in the console. Next, try creating a fake Jenkins job and adding that command as a build step. You should observe that only the first line is red. Thanks for your help! |
The problem is in JANSI, I made a pull request - fusesource/jansi#7. Will be able to fix this after it gets merged. |
Background colors are supported, the issue is around the default foreground (39) and background (49) values. If you don't have those, everything works. |
Way cool, @dblock! Thanks for looking into this. |
Fixed in 0843782. |
Awesome! Can't wait for the update in Jenkins. Thanks, @dblock! |
Hi @dblock, I just updated to 0.3.1 and unfortunately, I'm still not seeing color output from the Colorize gem. In addition, I can still reproduce the bug with the command I shared in an earlier comment. Here's a screenshot. Thanks for your help, again! |
Hmm… I think the upgrade worked. Jenkins restarted after the plugin installation, but I tried again just to be sure. Here's a screenshot of the "ANSI color map" function. |
Ok. I believe you. I tried on another Jenkins instance and got the same problem as you. And no problem on another. I think it has something to do with how update works - it's getting an older version of JANSI. |
It works with an older version of Hudson (I am testing with 1.374 for backwards compatibility). Any Jenkins fails at this specific example. It looks like the bash commands are executed somewhat differently. I'll debug this soon. Do you have any real colorize gem output in some rake task or something like that. Is that not working either? |
You may be on to something — I discovered two JANSI jar files in my installation:
Any recommendations? Yes, output from the colorize gem isn't working, either. Here's a little test that can be used:
Here's a screenshot of that command in my Jenkins (1.459). |
Looking at Colorize code it checks whether STDOUT is a terminal or something else. Try this:
Does this output red? (it does on mine) |
It does not output red: http://cl.ly/161x2u2j2O331S0w2847 |
Great catch, though! Presumably, this is the line you're referring to. I've confirmed that your overwriting of the
|
I got color! Thanks for your help, @dblock. In summary, there appears to be two bugs happening at once: Bug 1: the STDOUT.isatty conditional in the Colorize gem will prevent colorized output in Jenkins since
Workaround: overwrite the
Permanent fix: Unsure — I'm assuming this was done so colorized output isn't mistakenly piped somewhere else where it would be disagreeable (ex. a log file on disk). Bug 2: there are two versions of JANSI in my Jenkins installation (perhaps this is a Jenkins plugin upgrade/dependency management bug):
Workaround: remove/rename the older version and restart Jenkins:
Permanent fix: Unsure — any thoughts? |
Alright, so the original problem is really that AnsiColor that uses the old JANSI 1.6 was not properly removed. Good we figured it out. I posted this in the Jenkins google group. We shall see ... I think the Colorize gem needs a way to overwrite its behavior in a much cleaner way than a monkey patch. So I would fork and contribute something to it that lets me turn off isatty within a block, cleanly. |
Just wanted to add a couple updates to this ticket:
Thanks again for your help! |
Thanks @toddmazierski . I am not sure what the workitems out of this are - if you can find why you needed to do the renaming workaround, that'd be amazing - I never have to do this. |
Good news, JANSI was just bumped up to 1.9 a couple days ago. I think it means sooner or later I won't have to apply the patch any longer. |
Confirmed! This bug is now fixed in Jenkins 1.500. |
according to http://stackoverflow.com/questions/1401002/trick-an-application-into-thinking-its-stdin-is-interactive-not-a-pipe |
@dothebart Please contribute to the doc. |
Colored console output from the Colorize Ruby gem doesn't appear colorized in the Jenkins console.
In addition to the color code, the gem includes the mode and background color. Are these not supported?
Thanks!
The text was updated successfully, but these errors were encountered: