Skip to content

Commit

Permalink
locale: fix missing en_US.UTF-8 locale
Browse files Browse the repository at this point in the history
Summary:
See #814.
The "en_US.UTF-8" locale is not always valid. WSL uses `C.UTF-8` locale.
Change the `LANG` environment calculation to:
- Respect users' LANG setting if it's already UTF-8.
- Fallback to `C.UTF-8` instead of `en_US.UTF-8`, which works in WSL.

Reviewed By: evangrayk

Differential Revision: D52927838

fbshipit-source-id: c9110437e00382bb84e50d6b141fe5d4ce69f813
  • Loading branch information
quark-zju authored and facebook-github-bot committed Jan 22, 2024
1 parent 2652dab commit a3608fd
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions addons/isl-server/src/Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1261,27 +1261,32 @@ function getExecParams(
if (EXCLUDE_FROM_BLACKBOX_COMMANDS.has(commandName)) {
args.push('--config', 'extensions.blackbox=!');
}
const newEnv = {
...options_?.env,
...env,
// TODO: remove when SL_ENCODING is used everywhere
HGENCODING: 'UTF-8',
SL_ENCODING: 'UTF-8',
// override any custom aliases a user has defined.
SL_AUTOMATION: 'true',
SL_AUTOMATION_EXCEPT: 'phrevset', // allow looking up diff numbers even in plain mode
// Prevent user-specified merge tools from attempting to
// open interactive editors.
HGMERGE: ':merge3',
SL_MERGE: ':merge3',
EDITOR: undefined,
VISUAL: undefined,
HGUSER: undefined,
HGEDITOR: undefined,
} as unknown as NodeJS.ProcessEnv;
let langEnv = newEnv.LANG ?? process.env.LANG;
if (langEnv === undefined || !langEnv.toUpperCase().endsWith('UTF-8')) {
langEnv = 'C.UTF-8';
}
newEnv.LANG = langEnv;
const options: execa.Options = {
...options_,
env: {
...options_?.env,
...env,
LANG: 'en_US.utf-8', // make sure to use unicode if user hasn't set LANG themselves
// TODO: remove when SL_ENCODING is used everywhere
HGENCODING: 'UTF-8',
SL_ENCODING: 'UTF-8',
// override any custom aliases a user has defined.
SL_AUTOMATION: 'true',
SL_AUTOMATION_EXCEPT: 'phrevset', // allow looking up diff numbers even in plain mode
// Prevent user-specified merge tools from attempting to
// open interactive editors.
HGMERGE: ':merge3',
SL_MERGE: ':merge3',
EDITOR: undefined,
VISUAL: undefined,
HGUSER: undefined,
HGEDITOR: undefined,
} as unknown as NodeJS.ProcessEnv,
env: newEnv,
cwd,
};

Expand Down

0 comments on commit a3608fd

Please sign in to comment.