devbox icon indicating copy to clipboard operation
devbox copied to clipboard

Git Proxy - Handle UTF-8 output in all environments

Open ahirreddy opened this issue 4 years ago • 1 comments

Python auto-detects the default string encoding based on several environment variables:

LANG=C.UTF-8
LC_CTYPE=en_US.UTF-8

These are set by default in shells Devbox, and thus the encoding used by default is UTF-8. However, when invoking the git-shim from a shell where these variables are not set or as a subprocess (like from the test-shard CLI) - the default encoding is ASCII. This results in the following error whenever UTF-8 is present in the output of any command (usually a diff)

UnicodeEncodeError: 'ascii' codec can't encode characters in position <x>-<y>: ordinal not in range(128)

This PR fixes the issue by explicitly setting the encoding of the printed output to UTF-8 - so we don't need to rely on it being properly set in the environment or by callers.

ahirreddy avatar Feb 10 '21 21:02 ahirreddy

how urgent is this? can we merge this after we move devbox to universe?

gabrielrussoc avatar Feb 15 '21 13:02 gabrielrussoc