From b742a191ee543a1d8df255a2420a5bfe33672e2d Mon Sep 17 00:00:00 2001 From: browntarik <111317156+browntarik@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:36:09 -0800 Subject: [PATCH] Validate Compiler Paths Against PATH Environment Variable in Configuration UI (#11913) * resolve compiler against envrionment variables * fix lint issue --- Extension/src/LanguageServer/configurations.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index bebbc1772c..6c4b484ab3 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -1536,9 +1536,15 @@ export class CppProperties { // Check if config name is unique. errors.name = this.isConfigNameUnique(config.name); - + let resolvedCompilerPath: string | undefined; // Validate compilerPath - let resolvedCompilerPath: string | undefined = this.resolvePath(config.compilerPath); + if (config.compilerPath) { + resolvedCompilerPath = which.sync(config.compilerPath, { nothrow: true }) ?? undefined; + } + + if (resolvedCompilerPath === undefined) { + resolvedCompilerPath = this.resolvePath(config.compilerPath); + } const settings: CppSettings = new CppSettings(this.rootUri); const compilerPathAndArgs: util.CompilerPathAndArgs = util.extractCompilerPathAndArgs(!!settings.legacyCompilerArgsBehavior, resolvedCompilerPath); if (resolvedCompilerPath