Skip to content

Commit

Permalink
Apply custom env variables to terminal when in `pythonTerminalEnvVarA…
Browse files Browse the repository at this point in the history
…ctivation` experiment (microsoft#21879)

For microsoft#944 microsoft#20822 

We only apply those env vars to terminal which are not in process env
variables, hence remove custom env vars from process variables.
  • Loading branch information
Kartik Raj authored Aug 28, 2023
1 parent 3fa5d4b commit 98428cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/client/common/process/processFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export class ProcessServiceFactory implements IProcessServiceFactory {
@inject(IProcessLogger) private readonly processLogger: IProcessLogger,
@inject(IDisposableRegistry) private readonly disposableRegistry: IDisposableRegistry,
) {}
public async create(resource?: Uri): Promise<IProcessService> {
const customEnvVars = await this.envVarsService.getEnvironmentVariables(resource);
public async create(resource?: Uri, options?: { doNotUseCustomEnvs: boolean }): Promise<IProcessService> {
const customEnvVars = options?.doNotUseCustomEnvs
? undefined
: await this.envVarsService.getEnvironmentVariables(resource);
const proc: IProcessService = new ProcessService(customEnvVars);
this.disposableRegistry.push(proc);
return proc.on('exec', this.processLogger.logProcess.bind(this.processLogger));
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/process/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface IProcessService extends IDisposable {
export const IProcessServiceFactory = Symbol('IProcessServiceFactory');

export interface IProcessServiceFactory {
create(resource?: Uri): Promise<IProcessService>;
create(resource?: Uri, options?: { doNotUseCustomEnvs: boolean }): Promise<IProcessService>;
}

export const IPythonExecutionFactory = Symbol('IPythonExecutionFactory');
Expand Down
2 changes: 1 addition & 1 deletion src/client/interpreter/activation/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi
args[i] = arg.toCommandArgumentForPythonExt();
});
const command = `${interpreterPath} ${args.join(' ')}`;
const processService = await this.processServiceFactory.create(resource);
const processService = await this.processServiceFactory.create(resource, { doNotUseCustomEnvs: true });
const result = await processService.shellExec(command, {
shell,
timeout: ENVIRONMENT_TIMEOUT,
Expand Down

0 comments on commit 98428cd

Please sign in to comment.