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

Unescaped color output when running? #533

Open
hahuang65 opened this issue Feb 21, 2024 · 5 comments
Open

Unescaped color output when running? #533

hahuang65 opened this issue Feb 21, 2024 · 5 comments

Comments

@hahuang65
Copy link

hahuang65 commented Feb 21, 2024

Getting this output

^[]10;rgb:cdcd/d6d6/f4f4^[\^[[32;1R^[]11;rgb:1e1e/1e1e/2e2e^[\^[[32;36R when running.

Tried on multiple terminal emulators.

EDIT: This only happens on Linux. On Mac, with the same terminal emulator, and same settings, this doesn't happen.

go run github.com/cosmtrek/air@latest --build.cmd "go build -o /tmp/bin/foobar ./cmd/api" --build.bin "/tmp/bin/foobar"

  __    _   ___  
 / /\  | | | |_) 
/_/--\ |_| |_| \_ v1.50.0, built with Go go1.22.0

watching .
watching cmd
watching cmd/api
watching docker
watching docker/docker
watching docker/docker/prometheus.yml
watching internal
watching internal/env
watching internal/log
watching internal/otel
watching internal/request
watching internal/response
watching internal/validator
watching internal/version
watching prometheus.yml
!exclude tmp
building...
running...
^[]10;rgb:cdcd/d6d6/f4f4^[\^[[32;1R^[]11;rgb:1e1e/1e1e/2e2e^[\^[[32;36R2024-02-21 08:58:28 INFO <otel/otel.go:26> setting up telemetry endpoint=localhost:4317
2024-02-21 08:58:28 INFO <api/server.go:61> starting server server="[addr=:4444]"
@MKAbdElrahman
Copy link

I have the same issue.

@enrichman
Copy link

Yep, same. Everything is fine on my Mac, but on Linux I have this problem.

@graf0
Copy link

graf0 commented Mar 5, 2024

same here

@graf0
Copy link

graf0 commented Mar 5, 2024

It seems that problem is with using github.com/creack/pty in util_linux.go. And it's not caused by ie.: logging via log or slog. But after adding github.com/charmbracelet/wish I've got that strange effect.
I failed to diagnose which package is problematic. But in general - it seems that running command via pty is main problem.

Because by definition most program run by air are not pty programs ,but rather services/servers - I suggest adding no_pty optoin in such cases. So if you have problems with strage output like this:

^[]10;rgb:cdcd/d6d6/f4f4^[\^[[32;1R^[]11;rgb:1e1e/1e1e/2e2e^[\^[[32;36R

Set such option in .air.toml:

[screen]
  no_pty = true

That fixes problem.

@hahuang65
Copy link
Author

hahuang65 commented Mar 13, 2024

For what it's worth, another binary recently fixed this:

https://github.com/evilmartians/lefthook/releases/tag/v1.6.3

Specifically: evilmartians/lefthook@4c9e0e1

This is what it looks like:

$ go install github.com/evilmartians/lefthook@v1.6.2
$ lefthook version
1.6.2
$ lefthook run pre-commit
^[]11;rgb:0000/0000/0000^G╭──────────────────────────────────────╮
│ 🥊 lefthook v1.6.2  hook: pre-commit │
╰──────────────────────────────────────╯

vs

$ go install github.com/evilmartians/lefthook@v1.6.3
$ lefthook version
1.6.3
$ lefthook run pre-commit
╭──────────────────────────────────────╮
│ 🥊 lefthook v1.6.3  hook: pre-commit │
╰──────────────────────────────────────╯

Although, in my case, it may be related to the log package I'm using: charmbracelet/log#90

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

4 participants