Don't depend on en_US locale to be installed (#4949)

For some of the git commands that lazygit uses, it needs to force the
language to English because it parses git's output and needs to react to
certain things. It used to do this by setting the locale to
`en_US.UTF-8`; some users reported that this locale isn't available on
their systems. Use the "C" locale instead, which achieves the same
result and is guaranteed to be available everywhere.

Fixes #4731.
This commit is contained in:
Stefan Haller 2025-10-09 13:19:58 +02:00 committed by GitHub
commit 47ca08240b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View file

@ -244,8 +244,9 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(opts PrepareInteract
cmdObj.AddEnvVars(
"DEBUG="+debug,
"LANG=en_US.UTF-8", // Force using EN as language
"LC_ALL=en_US.UTF-8", // Force using EN as language
"LANG=C", // Force using English language
"LC_ALL=C", // Force using English language
"LC_MESSAGES=C", // Force using English language
"GIT_SEQUENCE_EDITOR="+gitSequenceEditor,
)
@ -277,8 +278,9 @@ func (self *RebaseCommands) GitRebaseEditTodo(todosFileContent []byte) error {
cmdObj.AddEnvVars(
"DEBUG="+debug,
"LANG=en_US.UTF-8", // Force using EN as language
"LC_ALL=en_US.UTF-8", // Force using EN as language
"LANG=C", // Force using English language
"LC_ALL=C", // Force using English language
"LC_MESSAGES=C", // Force using English language
"GIT_EDITOR="+ex,
"GIT_SEQUENCE_EDITOR="+ex,
)

View file

@ -330,7 +330,7 @@ func (self *cmdObjRunner) runAndDetectCredentialRequest(
promptUserForCredential func(CredentialType) <-chan string,
) error {
// setting the output to english so we can parse it for a username/password request
cmdObj.AddEnvVars("LANG=en_US.UTF-8", "LC_ALL=en_US.UTF-8")
cmdObj.AddEnvVars("LANG=C", "LC_ALL=C", "LC_MESSAGES=C")
return self.runAndStreamAux(cmdObj, func(handler *cmdHandler, cmdWriter io.Writer) {
tr := io.TeeReader(handler.stdoutPipe, cmdWriter)