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

Support FORCE_COLOR env var #341

Open
2 tasks done
MicaelJarniac opened this issue Jul 4, 2023 · 11 comments · May be fixed by #343
Open
2 tasks done

Support FORCE_COLOR env var #341

MicaelJarniac opened this issue Jul 4, 2023 · 11 comments · May be fixed by #343
Milestone

Comments

@MicaelJarniac
Copy link

MicaelJarniac commented Jul 4, 2023

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the FAQ and general documentation and believe that my question is not already covered.

Feature Request

Add support for the FORCE_COLOR environment variable. When set, regardless of value, all output should have colors enabled, as if the terminal supported them.

Some projects that use this:

Related:

@Secrus Secrus transferred this issue from python-poetry/poetry Jul 4, 2023
@MicaelJarniac
Copy link
Author

Worth noting, the main reason behind this is to have colored output when run in places like GitHub Actions.

I did experiment with using --ansi, and it did enable colors, but also ended up duplicating a lot of the lines.

I believe there may be something wrong with the way it redraws a line when it needs to update it.

Without --ansi (13 lines total):
Poetry output with no colors, 13 lines total

With --ansi (145 lines total):
Poetry output with color, many duplicate lines, 145 lines total

@Secrus
Copy link
Member

Secrus commented Jul 7, 2023

how does FORCE_COLOR standard corelate with NO_COLOR? Do you have any specifications or documentation, please?

@Secrus Secrus added this to the Future milestone Jul 7, 2023
@branchvincent branchvincent linked a pull request Jul 15, 2023 that will close this issue
@gsemet
Copy link

gsemet commented Jul 29, 2023

I agree. NO_COLOR forces to disable the color, but there are instances where there is no tty but we know colors are supported (github actions, or gitlab CI). Supporting a way to "allow color despit no tty" use case is a must.

Conan uses "NO_COLOR" and CONAN_FORCE_COLOR, with a precedence of NO_COLOR over CONAN_FORCE_COLOR.

I vote for POETRY_FORCE_COLOR to allow enabling colors only in poetry if need be

@MicaelJarniac
Copy link
Author

I'd say to support FORCE_COLOR, as to avoid the user having to constantly search around for what unique variable each tool uses, and maybe a POETRY_COLOR that can be set to something like "true" or "false", and takes precedence over both NO_COLOR and FORCE_COLOR, in case the user needs to configure just Poetry separately.

@adam-grant-hendry
Copy link

adam-grant-hendry commented Aug 23, 2023

Would this be different from setting ANSICON to a non-empty value?

From #10

As a workaround, you can set the ANSICON env-var to something non-empty to force ANSI support.

The relevant code from the source is here.

@adam-grant-hendry
Copy link

I believe there may be something wrong with the way it redraws a line when it needs to update it.

Without --ansi (13 lines total):
With --ansi (145 lines total):

That looks like verbose mode when --ansi is used...weird.

@MicaelJarniac
Copy link
Author

Would this be different from setting ANSICON to a non-empty value?

I suppose this could do the trick. I still think FORCE_COLOR would be nice, but this might help. Thanks for the tip!

@MicaelJarniac
Copy link
Author

That looks like verbose mode when --ansi is used...weird.

Do you happen to know if this has been fixed?

@adam-grant-hendry
Copy link

I still think FORCE_COLOR would be nice

Agreed. I have no idea where the hell ANSI_COLOR came from. I’m wondering if it should be removed or if it is an environment variable used for a specific Windows terminal…? I’m guessing the author meant it to indicate “do you want to use ANSI colors”, but once again, they did not document this!

My bet is it can be removed (unless someone can tell me if it is an environment variable used for a particular terminal).

Regardless, how to use environment variables needs to be documented!

@adam-grant-hendry
Copy link

Do you happen to know if this has been fixed?

I don’t know specifically about things being printed verbosely (as it appears in this case), but we did see duplicate printing of messages in poetry-relax issue #59, which I linked back to poetry issue #3097, which was fixed in poetry 1.3.0

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

Successfully merging a pull request may close this issue.

4 participants