diff --git a/src/client/terminals/envCollectionActivation/deactivateService.ts b/src/client/terminals/envCollectionActivation/deactivateService.ts index b763bd95e88c..0758f3e22311 100644 --- a/src/client/terminals/envCollectionActivation/deactivateService.ts +++ b/src/client/terminals/envCollectionActivation/deactivateService.ts @@ -8,7 +8,7 @@ import { ITerminalManager } from '../../common/application/types'; import { pathExists } from '../../common/platform/fs-paths'; import { _SCRIPTS_DIR } from '../../common/process/internal/scripts/constants'; import { identifyShellFromShellPath } from '../../common/terminal/shellDetectors/baseShellDetector'; -import { TerminalShellType } from '../../common/terminal/types'; +import { ITerminalHelper, TerminalShellType } from '../../common/terminal/types'; import { Resource } from '../../common/types'; import { waitForCondition } from '../../common/utils/async'; import { cache } from '../../common/utils/decorators'; @@ -37,6 +37,7 @@ export class TerminalDeactivateService implements ITerminalDeactivateService { constructor( @inject(ITerminalManager) private readonly terminalManager: ITerminalManager, @inject(IInterpreterService) private readonly interpreterService: IInterpreterService, + @inject(ITerminalHelper) private readonly terminalHelper: ITerminalHelper, ) {} @cache(-1, true) @@ -58,7 +59,11 @@ export class TerminalDeactivateService implements ITerminalDeactivateService { globalInterpreters.length > 0 && globalInterpreters[0] ? globalInterpreters[0].path : 'python'; const checkIfFileHasBeenCreated = () => pathExists(outputFile); const stopWatch = new StopWatch(); - terminal.sendText(`${interpreterPath} "${this.envVarScript}" "${outputFile}"`); + const command = this.terminalHelper.buildCommandForTerminal(shellType, interpreterPath, [ + this.envVarScript, + outputFile, + ]); + terminal.sendText(command); await waitForCondition(checkIfFileHasBeenCreated, 30_000, `"${outputFile}" file not created`); traceVerbose(`Time taken to get env vars using terminal is ${stopWatch.elapsedTime}ms`); } diff --git a/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts b/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts index daf3150fdbd0..c1955c2704e6 100644 --- a/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts +++ b/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts @@ -341,7 +341,7 @@ suite('Terminal Environment Variable Collection Service', () => { test('Also prepend deactivate script location if available', async () => { reset(terminalDeactivateService); - when(terminalDeactivateService.initializeScriptParams(anything())).thenResolve(); + when(terminalDeactivateService.initializeScriptParams(anything())).thenReject(); // Verify we swallow errors from here when(terminalDeactivateService.getScriptLocation(anything(), anything())).thenResolve('scriptLocation'); const processEnv = { PATH: 'hello/1/2/3' }; reset(environmentActivationService);