Skip to content

Commit 47ca082

Browse files
authored
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.
2 parents c31b604 + 99a83ef commit 47ca082

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pkg/commands/git_commands/rebase.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,9 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(opts PrepareInteract
244244

245245
cmdObj.AddEnvVars(
246246
"DEBUG="+debug,
247-
"LANG=en_US.UTF-8", // Force using EN as language
248-
"LC_ALL=en_US.UTF-8", // Force using EN as language
247+
"LANG=C", // Force using English language
248+
"LC_ALL=C", // Force using English language
249+
"LC_MESSAGES=C", // Force using English language
249250
"GIT_SEQUENCE_EDITOR="+gitSequenceEditor,
250251
)
251252

@@ -277,8 +278,9 @@ func (self *RebaseCommands) GitRebaseEditTodo(todosFileContent []byte) error {
277278

278279
cmdObj.AddEnvVars(
279280
"DEBUG="+debug,
280-
"LANG=en_US.UTF-8", // Force using EN as language
281-
"LC_ALL=en_US.UTF-8", // Force using EN as language
281+
"LANG=C", // Force using English language
282+
"LC_ALL=C", // Force using English language
283+
"LC_MESSAGES=C", // Force using English language
282284
"GIT_EDITOR="+ex,
283285
"GIT_SEQUENCE_EDITOR="+ex,
284286
)

pkg/commands/oscommands/cmd_obj_runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func (self *cmdObjRunner) runAndDetectCredentialRequest(
330330
promptUserForCredential func(CredentialType) <-chan string,
331331
) error {
332332
// setting the output to english so we can parse it for a username/password request
333-
cmdObj.AddEnvVars("LANG=en_US.UTF-8", "LC_ALL=en_US.UTF-8")
333+
cmdObj.AddEnvVars("LANG=C", "LC_ALL=C", "LC_MESSAGES=C")
334334

335335
return self.runAndStreamAux(cmdObj, func(handler *cmdHandler, cmdWriter io.Writer) {
336336
tr := io.TeeReader(handler.stdoutPipe, cmdWriter)

0 commit comments

Comments
 (0)