Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix diagnostic to use "System32" instead of "SystemRoot" #20937

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { traceError } from '../../../logging';
import { getExecutable } from '../../../common/process/internal/python';
import { getSearchPathEnvVarNames } from '../../../common/utils/exec';
import { IProcessServiceFactory } from '../../../common/process/types';
import { normCasePath } from '../../../common/platform/fs-paths';

const messages = {
[DiagnosticCodes.NoPythonInterpretersDiagnostic]: l10n.t(
Expand All @@ -46,7 +47,7 @@ const messages = {
'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.',
),
[DiagnosticCodes.IncompletePathVarDiagnostic]: l10n.t(
'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.',
'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.',
),
[DiagnosticCodes.DefaultShellErrorDiagnostic]: l10n.t(
'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.',
Expand Down Expand Up @@ -176,7 +177,6 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService
}

private async diagnoseDefaultShell(resource: Resource): Promise<IDiagnostic[]> {
await this.isPathVarIncomplete();
if (getOSType() !== OSType.Windows) {
return [];
}
Expand Down Expand Up @@ -215,9 +215,10 @@ export class InvalidPythonInterpreterService extends BaseDiagnosticsService
private isPathVarIncomplete() {
const envVars = getSearchPathEnvVarNames();
const systemRoot = getEnvironmentVariable('SystemRoot') ?? 'C:\\WINDOWS';
const system32 = path.join(systemRoot, 'system32');
for (const envVar of envVars) {
const value = getEnvironmentVariable(envVar);
if (value?.includes(systemRoot)) {
if (value && normCasePath(value).includes(normCasePath(system32))) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ suite('Application Diagnostics - Checks Python Interpreter', () => {
processService
.setup((p) => p.shellExec(typemoq.It.isAny(), typemoq.It.isAny()))
.returns(() => Promise.reject({ errno: -4058 }));
process.env.Path = 'C:\\Windows\\System32';
const diagnostics = await diagnosticService._manualDiagnose(undefined);
expect(diagnostics).to.be.deep.equal(
[new DefaultShellDiagnostic(DiagnosticCodes.DefaultShellErrorDiagnostic, undefined)],
Expand Down