Skip to content

Commit 8d8784f

Browse files
author
Kartik Raj
authored
Fix diagnostic to use "System32" instead of "SystemRoot" (#20937)
For #16692 Follow up to #20927
1 parent ef6511e commit 8d8784f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/client/application/diagnostics/checks/pythonInterpreter.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { traceError } from '../../../logging';
3434
import { getExecutable } from '../../../common/process/internal/python';
3535
import { getSearchPathEnvVarNames } from '../../../common/utils/exec';
3636
import { IProcessServiceFactory } from '../../../common/process/types';
37+
import { normCasePath } from '../../../common/platform/fs-paths';
3738

3839
const messages = {
3940
[DiagnosticCodes.NoPythonInterpretersDiagnostic]: l10n.t(
@@ -46,7 +47,7 @@ const messages = {
4647
'We detected an issue with one of your environment variables that breaks features such as IntelliSense, linting and debugging. Try setting the "ComSpec" variable to a valid Command Prompt path in your system to fix it.',
4748
),
4849
[DiagnosticCodes.IncompletePathVarDiagnostic]: l10n.t(
49-
'We detected an issue with "Path" environment variable that breaks features such as IntelliSense, linting and debugging. Please edit it to make sure it contains the "SystemRoot" subdirectories.',
50+
'We detected an issue with "Path" environment variable that breaks features such as IntelliSense, linting and debugging. Please edit it to make sure it contains the "System32" subdirectories.',
5051
),
5152
[DiagnosticCodes.DefaultShellErrorDiagnostic]: l10n.t(
5253
'We detected an issue with your default shell that breaks features such as IntelliSense, linting and debugging. Try resetting "ComSpec" and "Path" environment variables to fix it.',
@@ -176,7 +177,6 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService
176177
}
177178

178179
private async diagnoseDefaultShell(resource: Resource): Promise<IDiagnostic[]> {
179-
await this.isPathVarIncomplete();
180180
if (getOSType() !== OSType.Windows) {
181181
return [];
182182
}
@@ -215,9 +215,10 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService
215215
private isPathVarIncomplete() {
216216
const envVars = getSearchPathEnvVarNames();
217217
const systemRoot = getEnvironmentVariable('SystemRoot') ?? 'C:\\WINDOWS';
218+
const system32 = path.join(systemRoot, 'system32');
218219
for (const envVar of envVars) {
219220
const value = getEnvironmentVariable(envVar);
220-
if (value?.includes(systemRoot)) {
221+
if (value && normCasePath(value).includes(normCasePath(system32))) {
221222
return false;
222223
}
223224
}

src/test/application/diagnostics/checks/pythonInterpreter.unit.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
280280
processService
281281
.setup((p) => p.shellExec(typemoq.It.isAny(), typemoq.It.isAny()))
282282
.returns(() => Promise.reject({ errno: -4058 }));
283+
process.env.Path = 'C:\\Windows\\System32';
283284
const diagnostics = await diagnosticService._manualDiagnose(undefined);
284285
expect(diagnostics).to.be.deep.equal(
285286
[new DefaultShellDiagnostic(DiagnosticCodes.DefaultShellErrorDiagnostic, undefined)],

0 commit comments

Comments
 (0)