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

When precompiling without a terminal support reset crayon string is blank #246

Open
ktdq opened this issue Sep 29, 2024 · 7 comments
Open

Comments

@ktdq
Copy link

ktdq commented Sep 29, 2024

const _reset_crayon_str = string(_reset_crayon) is evaluated during precompilation of the package. But when there's no terminal support it becomes an empty string. When loaded afterwards with a proper terminal it fails to draw things correctly.

Need to ensure that the initialization of _reset_crayon_str occurs at runtime rather than at compile time.

@ronisbr
Copy link
Owner

ronisbr commented Sep 30, 2024

Thanks @ktdq ! Do you have any MWE so that I can test?

@ktdq
Copy link
Author

ktdq commented Sep 30, 2024

Something along these lines:

$ ssh localhost 'julia -e "using PrettyTables; @show(string(PrettyTables._reset_crayon))"' < /dev/null > out 2>&1
$ sleep 5
$ cat out
string(PrettyTables._reset_crayon) = ""
$ julia -e "using PrettyTables; @show(string(PrettyTables._reset_crayon))"
string(PrettyTables._reset_crayon) = "\e[0m"

I use ssh to precompile on a cluster, and there's no terminal...

@ktdq
Copy link
Author

ktdq commented Sep 30, 2024

What is wrong with just hardcoding the string?

const _reset_crayon_str = "\e[0m"

@ronisbr
Copy link
Owner

ronisbr commented Sep 30, 2024

Hum, that will be difficult to reproduce in the CI. Maybe hardcoding the string is the only safe solution then.

@ktdq
Copy link
Author

ktdq commented Sep 30, 2024

Just tried, hardcoding doesn't work when there's no terminal. You really want an empty string in this case otherwise you have extra escape codes in otherwise plain text output.

@ktdq
Copy link
Author

ktdq commented Sep 30, 2024

The only safe way is to remove _reset_crayon_str completely and let Crayon.jl logic figure out if _reset_crayon should print anything or not.

@ronisbr
Copy link
Owner

ronisbr commented Sep 30, 2024

Ok, thanks.

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

No branches or pull requests

2 participants