docker-library / buildpack-deps

MIT License
450 stars 115 forks source link

UTF-8 character in output has incorrect display width #148

Closed jkeech closed 11 months ago

jkeech commented 1 year ago

Hi! We use buildpack-deps as a base image for some Devcontainer images for interactive development environments, and we got a bug report about UTF-8 characters in a bash shell causing output to be overwritten.

Here's a minimal repro:

docker run --rm -it buildpack-deps:jammy-curl
root@7cfc2546c1ac:/# echo ➜

Then, alternate between the up and down arrow keys to cycle through commands in the command history and notice characters in the shell getting overwritten.

https://github.com/docker-library/buildpack-deps/assets/746020/f1deae6a-78ff-4329-b45e-5f60e59372d3

You can also verify the computed display width using echo ➜ | wc -L which should output 1 but instead outputs 0.

This issue does not reproduce when using ubuntu:jammy as the base image. Going through the Dockerfile one step at a time, the issue happens after gnugp is installed, although it's not clear to me why: https://github.com/docker-library/buildpack-deps/blob/93d6db0797f91ab674535553b7e0e762941a02d0/ubuntu/jammy/curl/Dockerfile#L14

Manually setting LANG=C.utf8 fixes the issue. Would it make sense to set this directly in the buildpack-deps image? Or is there some other reason the default lang/locale works on ubuntu:jammy but not on buildpack-deps?

tianon commented 11 months ago

We (intentionally) don't do much/any configuration here -- we just install a bunch of upstream Debian and Ubuntu packages. :sweat_smile:

I would imagine that installing gnupg is installing some locale related files (or regenerating them?) but I'm 100% guessing. I would suggest that this bug is probably more productive to chase somewhere in Ubuntu/Debian instead. :see_no_evil: