Skip to content

Commit 58d8ee0

Browse files
committed
fix: merge options.env with process.env instead of replacing
1 parent e28e1af commit 58d8ee0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/common/childProcess.apis.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ export interface ExecResult {
2020
* @returns A promise that resolves with { stdout, stderr } strings.
2121
*/
2222
export async function execProcess(command: string, options?: cp.ExecOptions): Promise<ExecResult> {
23+
// Always inherit process.env, then merge options.env overrides, with PYTHONUTF8 as default
2324
const env = {
2425
PYTHONUTF8: '1',
25-
...(options?.env ?? process.env),
26+
...process.env,
27+
...options?.env,
2628
};
2729
// Force encoding: 'utf8' to guarantee string output (cp.exec can return Buffers otherwise)
2830
const result = await cpExec(command, { ...options, env, encoding: 'utf8' });
@@ -56,10 +58,11 @@ export function spawnProcess(
5658
args: string[],
5759
options?: cp.SpawnOptions,
5860
): cp.ChildProcess | cp.ChildProcessWithoutNullStreams {
59-
// Set PYTHONUTF8=1; user-provided PYTHONUTF8 values take precedence.
61+
// Always inherit process.env, then merge options.env overrides, with PYTHONUTF8 as default
6062
const env = {
6163
PYTHONUTF8: '1',
62-
...(options?.env ?? process.env),
64+
...process.env,
65+
...options?.env,
6366
};
6467
return cp.spawn(command, args, { ...options, env });
6568
}

0 commit comments

Comments
 (0)