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

ruff check file.py output is unreadable #3568

Closed
copperfield42 opened this issue Mar 17, 2023 · 28 comments
Closed

ruff check file.py output is unreadable #3568

copperfield42 opened this issue Mar 17, 2023 · 28 comments
Labels
bug Something isn't working question Asking for support or clarification

Comments

@copperfield42
Copy link

Hello, I just hear of this project so I installed to test it, following the usage indication on some file I got this

image

I installed it like pip install ruff
ruff version: 0.0.256
Python version 3.11.2
OS: Windows 10

@charliermarsh
Copy link
Member

It looks like the color-support detection isn't working. Can you try setting NO_COLOR=1?

(Reference in docs: https://beta.ruff.rs/docs/faq/#how-can-i-disable-ruffs-color-output)

@charliermarsh
Copy link
Member

(Not sure why it's not working, but we delegate to another library for that: https://crates.io/crates/colored)

@charliermarsh charliermarsh added the question Asking for support or clarification label Mar 17, 2023
@copperfield42
Copy link
Author

creating and setting the NO_COLOR enviroment variable like that I got

image

now is readable

@copperfield42
Copy link
Author

I guess I have to install that colored library too...

@copperfield42
Copy link
Author

mmm apparently I have to download a 625mb installer to get the docker thing in order to install the colored library!? what? that is a little too much

@charliermarsh
Copy link
Member

No no sorry! You don't need to install that library at all. It's a library that Rust uses under the hood to output the colored escape characters, which many terminals recognize. It's supposed to detect whether your terminal supports those characters, and only output them if it does. In your case, it looks like your terminal doesn't support those characters, but the library is emitting them anyway. (E.g., on my machine, I didn't install that library outside of Ruff, but I do get colored output.)

In short: you don't need to install anything, but for whatever reason, it seems you either need to disable color via the environment variable (so that the library doesn't even try to output color), or try in a different terminal.

@copperfield42
Copy link
Author

that is weird, it display color correctly for other thing like those of pip, and with the colorama library (that is needed for the tqdm to display correctly) also work fine, after calling the just_fix_windows_console

image

removing the environment and trying in the power shell I got the same

image

here is a test script with the colorama

from colorama import Fore, Back, Style, just_fix_windows_console

just_fix_windows_console()

print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')

commenting the just_fix_windows_console it display

image

with just_fix_windows_console

image

maybe there is something similar with that colored library too?

@charliermarsh
Copy link
Member

Hmm, I'm not 100% sure -- it says Works on Linux, MacOS, and Windows (Powershell) so it's at least supposed to work in PowerShell.

@charliermarsh
Copy link
Member

There's some commentary in colored-rs/colored#59 where it seems like it doesn't work in some cases on Windows, but that it's not clear when.

@charliermarsh
Copy link
Member

@charliermarsh
Copy link
Member

Maybe I should be setting that on Windows?

@charliermarsh charliermarsh added the bug Something isn't working label Mar 17, 2023
@copperfield42
Copy link
Author

well, lets try and see.
constituent there also said something about that

@charliermarsh
Copy link
Member

Are you interested in building Ruff locally to test that?

@copperfield42
Copy link
Author

sure, what I need to do?

@charliermarsh
Copy link
Member

Could you clone this branch (#3583), then run:

cargo run -p ruff_cli -- /path/to/your/file.py --no-cache

@charliermarsh
Copy link
Member

You'd need to have Rust installed, so if that's too big of a lift, let me know. Maybe someone else can test.

@copperfield42
Copy link
Author

it is big lift, Rust is very heavy, well the Visual Studio part is, that 950mb in just the c++ compiler or whatever holy molly and if it need the win 11 sdk is 1.5gb DX

@copperfield42
Copy link
Author

if that branch can be made to be pip installed or similar without needing to install rust I can test it

@charliermarsh
Copy link
Member

Ok thanks, let me create a wheel.

@charliermarsh
Copy link
Member

I created wheels and binaries from that branch here: https://github.com/charliermarsh/ruff/actions/runs/4450737152

You can download them at the bottom, and find the appropriate one for your platform. LMK if that works...

@copperfield42
Copy link
Author

image

it appear to work correctly now :)

@charliermarsh
Copy link
Member

Woohoo! I'll clean up that PR.

@navneethc
Copy link

Can you use Windows Terminal?

@copperfield42
Copy link
Author

the power shell? sure
image

@navneethc
Copy link

the power shell? sure image

No, Windows Terminal -- it's the more modern alternative to the traditional terminal emulator. I'd recommend using that. It's available via the Windows Store: https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701

@copperfield42
Copy link
Author

sure, give me a moment to install it

@copperfield42
Copy link
Author

image

in that one there is no issue with either version of ruff

@navneethc
Copy link

navneethc commented Mar 17, 2023

image

in that one there is no issue with either version of ruff

Yeah, that's why I recommended it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

3 participants