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

v3: color output doesn't work properly on Windows #343

Closed
wdscxsj opened this issue Jun 12, 2020 · 7 comments
Closed

v3: color output doesn't work properly on Windows #343

wdscxsj opened this issue Jun 12, 2020 · 7 comments
Labels
os: windows Issues that affect users on Windows. type: bug Something not working as intended.

Comments

@wdscxsj
Copy link

wdscxsj commented Jun 12, 2020

  • Task version: 3.0.0-preview4
  • Windows version: Windows 10 Enterprise 1909 64-bit

Taskfile.yml:

# https://taskfile.dev

version: '3'

tasks:
  default:
    cmds:
      - winver

Color output doesn't work in cmd.exe and powershell.exe:

1

Works well in ConEmu and Terminal:

2

With version: '2', it works well in ConEmu and Terminal (with no color), but still fails in cmd.exe and powershell.exe:

3

Maybe mattn's colorable is a good solution?

@andreynering andreynering added type: bug Something not working as intended. os: windows Issues that affect users on Windows. labels Jun 13, 2020
@telenieko
Copy link

Just got hit by that. Command help hints that it should be possible to disable colored output, there is a flag to enable it, but it is enabled by default.

Options:
  -c, --color             colored output (default true)

Either --no-color or #459 should be available for us poor windows users without color :(

@ivotron
Copy link

ivotron commented Apr 1, 2021

an alternative is to use --color=false . does that work on your end?

@telenieko
Copy link

an alternative is to use --color=false . does that work on your end?

That seems to have no effect on windows (v3.3.0)

❯ task --color=false test
←[0mtask: Command........

@andreynering
Copy link
Member

Hi everybody, thanks for reporting this!

No sure what's happening on Windows. By the screenshots seems that it's not supported on CMD. Did anyone try on PowerShell?

--color=false is supported and does work on macOS. Need to check on Windows to see what's happening...

Anyway, just added support for NO_COLOR=1 as well so perhaps that works for now...

@telenieko
Copy link

No sure what's happening on Windows. By the screenshots seems that it's not supported on CMD. Did anyone try on PowerShell?

I am on PowerShell Core (Run: pwsh.exe)

--color=false is supported and does work on macOS. Need to check on Windows to see what's happening...
Anyway, just added support for NO_COLOR=1 as well so perhaps that works for now...

Testing:

❯ task test
←[32mtask: [test] echo "hello go-task"
←[0mhello go-task

❯ task test --color=false
←[0mtask: [test] echo "hello go-task"
←[0mhello go-task

❯ $env:NO_COLOR=1
❯ task test
task: [test] echo "hello go-task"
hello go-task

@silvanocerza
Copy link

I've investigated a bit this issue and found out some things.
If you run a task that has more than one task as dependency the colored output doesn't work only for the first one, subsequent ones will have no issues.

e.g.
Running this:

  python:lint:
    desc: Lint Python code
    deps:
      - task: poetry:install-deps
    cmds:
      - poetry run flake8 --show-source

produces this:

image

This line is the "culprit":

return r.Run(ctx, p)

You can easily verify that's the cause by changing that line to:

	logger.Blue()(opts.Stdout, "NOT COLORED FIRST TIME\n")
	err = r.Run(ctx, p)
	logger.Blue()(opts.Stdout, "COLORED ALWAYS\n")
	return err

This is the result:
image

Am not sure how to best fix this issue, I don't have enough knowledge about the codebase. There's probably some strange thing going on with stdout and stderr. 😕

Hope this helps.

@pd93
Copy link
Member

pd93 commented Jun 27, 2023

I've just tried the sample on Windows 11 with Task v3.26 on both cmd and powershell and it looks fine to me. Since this was reported in the Task v3 preview and no-one has commented or referenced this issue for nearly 2 years, I'm going to close it.

If anyone is still having this problem or thinks this isn't fixed, please open a new issue with steps to reproduce it.

@pd93 pd93 closed this as completed Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os: windows Issues that affect users on Windows. type: bug Something not working as intended.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants