Skip to content

Commit 30cbd03

Browse files
Kartik Rajanthonykim1
Kartik Raj
authored andcommitted
Do not assume casing of activated environment variables Python returns (microsoft#21970)
For microsoft#20950
1 parent 3023443 commit 30cbd03

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/client/interpreter/activation/terminalEnvVarCollectionService.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,13 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
133133
traceVerbose('Activating environments in terminal is disabled for', resource?.fsPath);
134134
return;
135135
}
136-
const env = await this.environmentActivationService.getActivatedEnvironmentVariables(
136+
const activatedEnv = await this.environmentActivationService.getActivatedEnvironmentVariables(
137137
resource,
138138
undefined,
139139
undefined,
140140
shell,
141141
);
142+
const env = activatedEnv ? normCaseKeys(activatedEnv) : undefined;
142143
if (!env) {
143144
const shellType = identifyShellFromShellPath(shell);
144145
const defaultShell = defaultShells[this.platform.osType];
@@ -158,7 +159,7 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
158159
shell,
159160
);
160161
}
161-
const processEnv = this.processEnvVars;
162+
const processEnv = normCaseKeys(this.processEnvVars);
162163

163164
// PS1 in some cases is a shell variable (not an env variable) so "env" might not contain it, calculate it in that case.
164165
env.PS1 = await this.getPS1(shell, resource, env);
@@ -376,3 +377,11 @@ function getPromptForEnv(interpreter: PythonEnvironment | undefined) {
376377
}
377378
return undefined;
378379
}
380+
381+
function normCaseKeys(env: EnvironmentVariables): EnvironmentVariables {
382+
const result: EnvironmentVariables = {};
383+
Object.keys(env).forEach((key) => {
384+
result[key.toUpperCase()] = env[key];
385+
});
386+
return result;
387+
}

0 commit comments

Comments
 (0)