-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Color support detectiong change in 6.3.11 introduced a regression #53460
Comments
Running the command with tests/fixtures/e2e/test.php "$(NO_COLOR=1 DDQG_COMPOSER_AUDIT_TEST_ENV=1 ./vendor/bin/composer -d tests/fixtures/e2e audit --format=json)" |
Noticed the same thing upon upgrading to 5.4.34, the output is being decorated even when not attached to a tty.
|
The issue with env-based detection is indeed that this applies even when redirecting the output to something else. I think #52940 should be reverted /cc @theofidry |
@stof what would be the best way to fix? If you only revert, you are adding back the bug fixed too, and that means the bug described in this ticket already exists if you have a In the case of composer, isn't it Composer's responsibility to disable the decorated output for this format?
Could be due to an environment variable from the session in which case it is expected? |
Yes it's picking up that I have |
Hm, indeed, it could handle that.
--no-ansi is the change |
If this is too much of a change in the ecosystem it might be better to revert it and introduce it in a new version, although technically it is really a fix. IMO the case of Composer was a "happy accident" that it was working: it outputs a result in a specific format, so disabling output decoration should be done there (and it indicates it is broken in some terminals).
If you check #52940 you can see that is how it worked already before, it just failed to capture the WDYM by attaching the output to the terminal? |
@theofidry checking whether the output stream is a tty (instead of being a file where it is redirected for instance) is exactly what |
If the output is redirected or piped the output isn't attached to a terminal e.g. Basically every command on Linux works by detecting if the output is going directly to a terminal when deciding to apply output formatting, as an example note the first ls output where I've forced colour on which results in some funkiness. |
For the record, a recent update of symfony/console also break our application (our test suite, don't worry) and it also broke castor's test suite |
Will have a look at it tomorrow |
Based on your feedback it looks to me that Also note that this should affect the It also looks like, looking at https://github.com/composer/xdebug-handler/pull/123/files, that there could be an additional fallback or that the case It's a bit out of scope of the change so I guess for now it would be best to revert this with an explanation. I'll submit a PR during the week |
… if the output (theofidry) This PR was merged into the 5.4 branch. Discussion ---------- [Console] Only execute additional checks for color support if the output is a TTY | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #53460 | License | MIT As reported in #53460, the modifications done in #52940 are incorrect as it results in detecting that the stream can support colors despite not being a TTY. Rather than doing a simple revert which would re-introduce the pre-existing issue that #52940 attempted to fix, this PR checks if the output is a TTY based on Composer's code and does this check before anything else. Indeed a TTY only means that colors _may_ be supported, so the various checks that we were doing do make sense to be done but should be done after this TTY (so `Hyper` is not an exception, it can be a TTY or not). Commits ------- 2e96b22 [Console] Only execute additional checks for color support if the output is a TTY
Symfony version(s) affected
6.3.11
Description
See steps the reproduce.
How to reproduce
I have a custom KISS e2e test script for testing
composer audit
command outputs.It looks like the color support detection change that was introduced in 6.3.11 introduced a regression and the output of
composer audit --format=json
become colorized that makes the JSON invalid.(Source: https://github.com/mxr576/ddqg-composer-audit/blob/1.0.0-rc4/tests/fixtures/e2e/test.php#L18-L29)
tests/fixtures/e2e/test.php "$(DDQG_COMPOSER_AUDIT_TEST_ENV=1 ./vendor/bin/composer -d tests/fixtures/e2e audit --format=json)"
(Source: https://github.com/mxr576/ddqg-composer-audit/blob/1.0.0-rc4/.github/workflows/run-e2e-test.yml#L51)
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: