Skip to content

Commit d2ac600

Browse files
00zayneleanorjboyd
andauthored
Fix spurious unresolved interpreter warning from ${workspaceFolder}-scoped global defaultInterpreterPath (#1334)
Fixes #1316. Skip evaluating `${workspaceFolder}`-scoped `python.defaultInterpreterPath` during global resolution. Co-authored-by: Zayn <265647957+zayn-sh@users.noreply.github.com> Co-authored-by: Eleanor Boyd <26030610+eleanorjboyd@users.noreply.github.com>
1 parent c9389c6 commit d2ac600

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

src/features/interpreterSelection.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,33 @@ async function resolvePriorityChainCore(
128128
);
129129
}
130130
} else {
131-
const resolved = await tryResolveInterpreterPath(nativeFinder, api, expandedInterpreterPath, envManagers);
132-
if (resolved) {
133-
traceVerbose(`${logPrefix} Priority 3: Using defaultInterpreterPath: ${userInterpreterPath}`);
134-
return { result: resolved, errors };
131+
const expandedInterpreterPath = resolveVariables(userInterpreterPath, scope);
132+
if (expandedInterpreterPath.includes('${')) {
133+
traceWarn(
134+
`${logPrefix} defaultInterpreterPath '${userInterpreterPath}' contains unresolved variables, falling back to auto-discovery`,
135+
);
136+
const error: SettingResolutionError = {
137+
setting: 'defaultInterpreterPath',
138+
configuredValue: userInterpreterPath,
139+
reason: l10n.t('Path contains unresolved variables'),
140+
};
141+
errors.push(error);
142+
} else {
143+
const resolved = await tryResolveInterpreterPath(nativeFinder, api, expandedInterpreterPath, envManagers);
144+
if (resolved) {
145+
traceVerbose(`${logPrefix} Priority 3: Using defaultInterpreterPath: ${userInterpreterPath}`);
146+
return { result: resolved, errors };
147+
}
148+
const error: SettingResolutionError = {
149+
setting: 'defaultInterpreterPath',
150+
configuredValue: userInterpreterPath,
151+
reason: `Could not resolve interpreter path '${userInterpreterPath}'`,
152+
};
153+
errors.push(error);
154+
traceWarn(
155+
`${logPrefix} defaultInterpreterPath '${userInterpreterPath}' unresolvable, falling back to auto-discovery`,
156+
);
135157
}
136-
const error: SettingResolutionError = {
137-
setting: 'defaultInterpreterPath',
138-
configuredValue: userInterpreterPath,
139-
reason: `Could not resolve interpreter path '${userInterpreterPath}'`,
140-
};
141-
errors.push(error);
142-
traceWarn(
143-
`${logPrefix} defaultInterpreterPath '${userInterpreterPath}' unresolvable, falling back to auto-discovery`,
144-
);
145158
}
146159
}
147160

0 commit comments

Comments
 (0)