diff --git a/src/features/interpreterSelection.ts b/src/features/interpreterSelection.ts index d5780b69..f670b390 100644 --- a/src/features/interpreterSelection.ts +++ b/src/features/interpreterSelection.ts @@ -106,32 +106,38 @@ async function resolvePriorityChainCore( // PRIORITY 3: User-configured python.defaultInterpreterPath const userInterpreterPath = getUserConfiguredSetting('python', 'defaultInterpreterPath', scope); if (userInterpreterPath) { - const expandedInterpreterPath = resolveVariables(userInterpreterPath, scope); - if (expandedInterpreterPath.includes('${')) { - traceWarn( - `${logPrefix} defaultInterpreterPath '${userInterpreterPath}' contains unresolved variables, falling back to auto-discovery`, + if (!scope && userInterpreterPath.includes('${workspaceFolder}')) { + traceVerbose( + `${logPrefix} Skipping workspace-scoped defaultInterpreterPath during global resolution: ${userInterpreterPath}`, ); - const error: SettingResolutionError = { - setting: 'defaultInterpreterPath', - configuredValue: userInterpreterPath, - reason: l10n.t('Path contains unresolved variables'), - }; - errors.push(error); } else { - const resolved = await tryResolveInterpreterPath(nativeFinder, api, expandedInterpreterPath, envManagers); - if (resolved) { - traceVerbose(`${logPrefix} Priority 3: Using defaultInterpreterPath: ${userInterpreterPath}`); - return { result: resolved, errors }; + const expandedInterpreterPath = resolveVariables(userInterpreterPath, scope); + if (expandedInterpreterPath.includes('${')) { + traceWarn( + `${logPrefix} defaultInterpreterPath '${userInterpreterPath}' contains unresolved variables, falling back to auto-discovery`, + ); + const error: SettingResolutionError = { + setting: 'defaultInterpreterPath', + configuredValue: userInterpreterPath, + reason: l10n.t('Path contains unresolved variables'), + }; + errors.push(error); + } else { + const resolved = await tryResolveInterpreterPath(nativeFinder, api, expandedInterpreterPath, envManagers); + if (resolved) { + traceVerbose(`${logPrefix} Priority 3: Using defaultInterpreterPath: ${userInterpreterPath}`); + return { result: resolved, errors }; + } + const error: SettingResolutionError = { + setting: 'defaultInterpreterPath', + configuredValue: userInterpreterPath, + reason: `Could not resolve interpreter path '${userInterpreterPath}'`, + }; + errors.push(error); + traceWarn( + `${logPrefix} defaultInterpreterPath '${userInterpreterPath}' unresolvable, falling back to auto-discovery`, + ); } - const error: SettingResolutionError = { - setting: 'defaultInterpreterPath', - configuredValue: userInterpreterPath, - reason: `Could not resolve interpreter path '${userInterpreterPath}'`, - }; - errors.push(error); - traceWarn( - `${logPrefix} defaultInterpreterPath '${userInterpreterPath}' unresolvable, falling back to auto-discovery`, - ); } }