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 · 6 comments
Open

Unescaped color output when running? #533

hahuang65 opened this issue Feb 21, 2024 · 6 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/[email protected]
$ 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/[email protected]
$ 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

@Jawkx
Copy link

Jawkx commented Jun 27, 2024

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

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

5 participants