Skip to content

Commit

Permalink
Spawn processes with LANG that's guaranteed to exist (#506)
Browse files Browse the repository at this point in the history
`LANG=en_US` is not guaranteed to exist on any system (it does not, for
strange reasons, exist on mine). Choose `LANG=C`, which is guaranteed to
exist. It has the side-effect of typically using an encoding other than
UTF-8 for the tool output (e.g., ISO 8859-1). Apart from messages
printed into the log in this encoding that should hopefully have no
negative side-effects.

See #505 for a case where
code was assuming that output would always be English, and failed if it
wasn't.

Co-authored-by: Søren Louv-Jansen <[email protected]>
  • Loading branch information
imphil and sorenlouv authored Sep 6, 2024
1 parent 3ebe14d commit c824547
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/child-process-promisified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export async function spawnPromise(
const subprocess = childProcess.spawn(cmd, cmdArgs, {
cwd,

// ensure that git commands return english error messages
env: { ...process.env, LANG: 'en_US' },
// ensure that git commands return English error messages
env: { ...process.env, LANG: 'C' },
...(isInteractive ? { stdio: 'inherit' } : undefined),
});
let stderr = '';
Expand Down Expand Up @@ -95,7 +95,7 @@ export const spawnStream = (cmd: string, cmdArgs: ReadonlyArray<string>) => {
const spawnSpan = startSpawnSpan(cmd, cmdArgs);

const res = childProcess.spawn(cmd, cmdArgs, {
env: { ...process.env, LANG: 'en_US' },
env: { ...process.env, LANG: 'C' },
});

res.on('close', (code) => {
Expand Down

0 comments on commit c824547

Please sign in to comment.