Unescaped color output when running?
hahuang65 opened this issue · comments
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]"
I have the same issue.
Yep, same. Everything is fine on my Mac, but on Linux I have this problem.
same here
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.
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
Adding no_pty
to my config still haven't fix the issue
I'm using linux, zsh, kitty terminal
my air toml
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"
[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ./server/main.go"
delay = 1000
exclude_dir = ["bruno","bin"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
main_only = false
time = false
[misc]
clean_on_exit = false
[proxy]
app_port = 0
enabled = false
proxy_port = 0
[screen]
no_pty = true
output
❯ air
__ _ ___
/ /\ | | | |_)
/_/--\ |_| |_| \_ v1.52.3, built with Go go1.22.2
watching .
!exclude bin
!exclude bruno
watching cmd
watching db
watching handlers
watching model
watching public
watching server
watching storage
!exclude tmp
building...
running...
^[]10;rgb:bdbd/bdbd/bdbd^[\^[[21;1R^[]11;rgb:0808/0808/0808^[\^[[21;36R2024/06/27 11:13:48 INFO App running in port :8080