diff --git a/src/client/common/process/proc.ts b/src/client/common/process/proc.ts index 959d9b615f39..059302c9d349 100644 --- a/src/client/common/process/proc.ts +++ b/src/client/common/process/proc.ts @@ -15,9 +15,10 @@ export class ProcessService implements IProcessService { constructor( @inject(IBufferDecoder) private decoder: IBufferDecoder) { } public execObservable(file: string, args: string[], options: SpawnOptions = {}): ObservableExecutionResult { const encoding = options.encoding = typeof options.encoding === 'string' && options.encoding.length > 0 ? options.encoding : DEFAULT_ENCODING; + delete options.encoding; const spawnOptions = { ...options }; if (!spawnOptions.env || Object.keys(spawnOptions).length === 0) { - spawnOptions.env = process.env; + spawnOptions.env = { ...process.env }; } // Always ensure we have unbuffered output. @@ -74,9 +75,10 @@ export class ProcessService implements IProcessService { } public async exec(file: string, args: string[], options: SpawnOptions = {}): Promise> { const encoding = options.encoding = typeof options.encoding === 'string' && options.encoding.length > 0 ? options.encoding : DEFAULT_ENCODING; + delete options.encoding; const spawnOptions = { ...options }; if (!spawnOptions.env || Object.keys(spawnOptions).length === 0) { - spawnOptions.env = process.env; + spawnOptions.env = { ...process.env }; } // Always ensure we have unbuffered output. diff --git a/src/test/common/process/proc.exec.test.ts b/src/test/common/process/proc.exec.test.ts index 8ab71804d3d2..f04e77e1b9f4 100644 --- a/src/test/common/process/proc.exec.test.ts +++ b/src/test/common/process/proc.exec.test.ts @@ -35,7 +35,7 @@ suite('ProcessService', () => { test('exec should output print unicode characters', async () => { const procService = new ProcessService(new BufferDecoder()); const printOutput = 'öä'; - const result = await procService.exec(pythonPath, ['-c', `print(u"${printOutput}")`]); + const result = await procService.exec(pythonPath, ['-c', `print("${printOutput}")`]); expect(result).not.to.be.an('undefined', 'result is undefined'); expect(result.stdout.trim()).to.be.equal(printOutput, 'Invalid output');