From f57be20d7af6c623774cd148f07ed77c31607ee7 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 20 Oct 2023 15:59:11 -0700 Subject: [PATCH] Support powershell activation even if Powershell execution is disabled on the system (#22273) Closes https://github.com/microsoft/vscode-python/issues/22252 Error out if stderr is related to Powershell execution being disabled on system, even though environment variables are returned in this case, we've observed they're not valid in this case. --- src/client/interpreter/activation/service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/client/interpreter/activation/service.ts b/src/client/interpreter/activation/service.ts index 02d621c0ccda..5fda5a9380dc 100644 --- a/src/client/interpreter/activation/service.ts +++ b/src/client/interpreter/activation/service.ts @@ -329,7 +329,12 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi } if (result.stderr) { if (returnedEnv) { - traceWarn('Got env variables but with errors', result.stderr); + traceWarn('Got env variables but with errors', result.stderr, returnedEnv); + if (result.stderr.includes('running scripts is disabled')) { + throw new Error( + `Skipping returned result when powershell execution is disabled, stderr ${result.stderr} for ${command}`, + ); + } } else { throw new Error(`StdErr from ShellExec, ${result.stderr} for ${command}`); }