Open basaran opened 8 months ago
Run into this issue today also https://github.com/cosmtrek/air/issues/502
I have also had this same issue, but I have 2 things to add:
CI=true air ...
instead of running air directly - this will fix the slowness of rebuilding at the cost of not having coloured logs when using air.Hey there! This looks like a side effect from background color detection upstream in termenv (cc @muesli)
2. CI=true air
Thanks for the workaround
Looks like the issue is still here with latest 0.3.1 release which includes the fix
https://github.com/charmbracelet/log/assets/98523125/0ea6e749-bc13-4ac5-82ea-8bbec7af5757
package main
import (
"os"
"github.com/charmbracelet/log"
)
func main() {
log.NewWithOptions(os.Stdout, log.Options{})
log.Info("test")
}
Hey there! This looks like a side effect from background color detection upstream in termenv (cc @muesli)
It looks like this is a result of querying the cursor position (CPR) CSI 6 n
from termenv
Hi!
I get the same result of @basaran but only when running the app inside a docker container (compiles in golang:alpine
and runs in FROM scratch
).
This also slows down the startup/bootstrap of the application. CI=true
actually "fix" the issue about the chars but the slowdown is quite annoying.
FROM golang:alpine as app-builder
WORKDIR /go/src/app
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,target=. \
CGO_ENABLED=0 go build -ldflags '-extldflags "-static"' -tags timetzdata -o /go/bin/my_app
FROM scratch
COPY --from=app-builder /go/bin/my_app /my_app
COPY .env /.env
COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
HEALTHCHECK NONE
ENTRYPOINT [ "/my_app" ]
output of docker run
[+] Building 1.3s (14/14) FINISHED docker:default
=> [internal] load .dockerignore 0.0s
=> => transferring context: 176B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 629B
[... snip ...]
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:a45f84819330543d4d8d17759c2b069e6d73f88fffb10e0355accd27ea89e44d 0.0s
=> => naming to docker.io/library/my_app 0.0s
^[]10;rgb:fcfc/fcfc/fcfc^[\^[[49;1R^[]11;rgb:2323/2626/2727^[\^[[49;36R^[]10;rgb:fcfc/fcfc/fcfc^[\^[[49;72R^[]11;rgb:2323/2626/2727^[\^[[49;108R%
It looks like this was fixed by another package similarly to @aymanbagabas fix in #93
https://github.com/cosmtrek/air/issues/533#issuecomment-1993276683
This should be handled by https://github.com/charmbracelet/log/commit/28193306e6f5a221d00a74fa6e8683ea10ae06be released in v0.4.0, closing.
Unfortunately, this does not appear to be fixed with 0.4.0
:
air --build.cmd "go build -o /tmp/bin/baz ./cmd/api" --build.bin "/tmp/bin/baz" --build.delay "100" --build.exclude_dir "" --build.include_ext "go, tpl, tmpl, html, css, scss, js, ts, sql, jpeg, jpg, gif, png, bmp, svg, webp, ico" --misc.clean_on_exit "true"
__ _ ___
/ /\ | | | |_)
/_/--\ |_| |_| \_ v1.51.0, built with Go go1.22.1
mkdir /home/hao/Documents/Projects/baz/tmp
watching .
watching cmd
watching cmd/api
watching internal
watching internal/env
watching internal/log
watching internal/request
watching internal/response
watching internal/testhelper
watching internal/validator
watching internal/version
!exclude tmp
building...
running...
^[]10;rgb:cdcd/d6d6/f4f4^[\^[[99;1R^[]11;rgb:1e1e/1e1e/2e2e^[\^[[99;36R2024-03-23 10:56:02 INFO <api/server.go:49> starting server server="[addr=:4444]"
Considering the above ^, should I open a new ticket?
FWIW a more complete workaround, with the output still having colors, is to set these 2 envs:
CI=1
CLICOLOR_FORCE=1
Also encountering the same issue in WSL2 and air
Hello,
I use air as a live reload tool during development. When the log is used, I get scrambled ansi characters on the terminal (alacritty).
Here's a recording: https://github.com/charmbracelet/log/assets/30809170/36b68013-a03b-47e5-85aa-5f85f3058d30
Is this an air issue?