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

Default pager breaks colours in Windows Terminal #860

Closed
rgwood opened this issue Mar 10, 2020 · 25 comments
Closed

Default pager breaks colours in Windows Terminal #860

rgwood opened this issue Mar 10, 2020 · 25 comments
Labels
bug Something isn't working upstream-error A bug in an upstream component windows Issue is related to the Windows build of bat

Comments

@rgwood
Copy link

rgwood commented Mar 10, 2020

Hi, I've run into a bug in less that effectively breaks bat in the new Windows Terminal. I appreciate that this is not bat's fault, but I'm reporting it here to save other people the investigation time.

Bug

When calling bat in PowerShell in Windows Terminal, it breaks subsequent colouring in the terminal and makes it unusable (at least with my colour scheme) until the terminal is relaunched:

image

Details

This occurs for me in PowerShell (7 and 5.1) in Windows Terminal, it does not occur in the old Windows PowerShell application.

I believe this is due to a bug in version 551 of the less pager, which is installed by default with the bat Chocolatey package. The issue has been fixed in less source, but it's not available via Windows package managers yet.

Short-term workaround

I was able to fix the issue by compiling version 554 of less, using the MinGW compilation instructions here.

Long-term fix

Wait for a newer version of less to be released via Chocolatey and Scoop.

What version of bat are you using?
bat 0.12.1 and less 551

How did you install bat?
Chocolatey


Windows 10 1909

@rgwood rgwood added the bug Something isn't working label Mar 10, 2020
@sharkdp sharkdp added upstream-error A bug in an upstream component windows Issue is related to the Windows build of bat labels Mar 10, 2020
@sharkdp
Copy link
Owner

sharkdp commented Mar 10, 2020

Thank you for the detailed bug report!

We can keep this open until it has been fixed in the Chocolatey package. Apart from that, I don't think there is anything we can do here except to suggest an (obvious) workaround, which would be to put --paging=never in bats config file (bat --config-file):

# Disable paging
--paging=never

@sharkdp
Copy link
Owner

sharkdp commented Apr 11, 2020

less 557 has been recently released as a beta: http://greenwoodsoftware.com/less/download.html
The release notes mention "Fix display bug in WIN32C version."

Chocolatey:

Scoop:

@sharkdp
Copy link
Owner

sharkdp commented Apr 30, 2020

In the meantime, @gwsw released less v559. It would be great if someone could verify if it (still) solves this issue. It would be even better, if #887 could also be tested (see this comment and 864656b).

@ofek
Copy link

ofek commented May 4, 2020

@sharkdp less no longer provides binaries 🙁

@jftuga
Copy link

jftuga commented May 5, 2020

I have built less version 560 binaries for Windows. I have also documented the complete build process here:

https://github.com/jftuga/less-Windows

As a workaround, I have had good luck with really old versions of less.exe such as version 429 by setting the following environment variable:

BAT_STYLE=numbers,plain

Please note that this workaround is unnecessary for binary I am distributing in my GitHub repo.

@jftuga
Copy link

jftuga commented May 6, 2020

I updated my binary version of less tov560 which fixes an issue where colors were not being properly displayed under v557.

https://github.com/jftuga/less-Windows

@sharkdp
Copy link
Owner

sharkdp commented May 10, 2020

@jftuga Thank you very much for verifying this!

In this case, we only need to wait for the new releases to make it into Chocolatey/Scoop.

@jcotton42
Copy link

@sharkdp unfortunately as @ofek noted less is no longer providing binaries and the maintainer of the Chocolatey package is also dropping it.

@jftuga
Copy link

jftuga commented May 10, 2020

In addition to the Chocolatey information, under the Paging section, you could also link to my repo.

This could possibly be a resolution to this issue.

@ofek
Copy link

ofek commented May 11, 2020

@jftuga I'm using your builds, thanks!

@sharkdp
Copy link
Owner

sharkdp commented May 11, 2020

@sharkdp unfortunately as @ofek noted less is no longer providing binaries and the maintainer of the Chocolatey package is also dropping it.

Oh, I missed the reference to the comment section of the Chocolatey package. That is unfortunate (not the fact that less does not distribute binaries, but the fact that Chocolatey does not build executables from source).

In addition to the Chocolatey information, under the Paging section, you could also link to my repo.

I'd be okay with that, but I would much rather like this to be solved on the Chocolatey side. Maybe they could use the binary (binaries) from your repo?

@jftuga
Copy link

jftuga commented May 11, 2020

I have messaged the Chocolatey less maintainer with the link to my repo.

https://chocolatey.org/packages/Less#discussion

@ofek
Copy link

ofek commented May 11, 2020

@jftuga Instead of (or in addition to) Chocolatey, can you please update Scoop? https://github.com/ScoopInstaller/Main/blob/master/bucket/less.json

@jftuga
Copy link

jftuga commented May 20, 2020

Chocolatey is now using my version of less:

https://chocolatey.org/packages/Less

@ofek
Copy link

ofek commented May 20, 2020

@jftuga Yay! Would you mind doing Scoop too? I (& many I know) avoid Chocolatey.

@jftuga
Copy link

jftuga commented May 20, 2020

@ofek I made a PR for scoop

ScoopInstaller/Main#1108

@sharkdp
Copy link
Owner

sharkdp commented May 21, 2020

@jftuga Awesome work, thank you very much!

Can someone please confirm that the original bug has been fixed when freshly installing bat via Chocolatey?

@jftuga
Copy link

jftuga commented May 21, 2020

I can confirm that this is fixed with Chocolatey and bat 0.15.1 along with less 561. This was tested by using a fresh install of bat via Chocolatey.

@ofek
Copy link

ofek commented May 21, 2020

@jftuga Thank you!!!

@sharkdp
Copy link
Owner

sharkdp commented May 29, 2020

@ofek I made a PR for scoop

ScoopInstaller/Main#1108

This has been merged as well 🎉. If anyone can confirm that everything works as expected when installing via Scoop, we can finally close this ticket.

@sharkdp
Copy link
Owner

sharkdp commented Jun 5, 2020

Anyone here using the Scoop-installed version of bat?

@patevs
Copy link

patevs commented Jun 5, 2020

@sharkdp Yes I have bat installed using scoop.

@sharkdp
Copy link
Owner

sharkdp commented Jun 6, 2020

Ok, I'm going to close this for now. Let me know if this should re-appear in some setting.

Thank you all for your help.

@johnknoop
Copy link

johnknoop commented Nov 11, 2024

I don't know if this is same same issue resurfacing, or if it's new. But I have jftuga.less installed via winget, and all colors are stripped when running bat. Right now I've disabled paging in the Bat config file, because I value colors higher than paging, but it would be great if I could have both.

Nvm, I wasn't running the latest version of less.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream-error A bug in an upstream component windows Issue is related to the Windows build of bat
Projects
None yet
Development

No branches or pull requests

7 participants