Skip to content

Commit d84e05b

Browse files
Fix python.defaultInterpreterPath0. setting not being applied to new workspaces (#1110)
The PR is a follow-up task to the sync meeting and the discussion in #861 (comment) The PR fixes a bug where the `python.defaultInterpreterPath` setting was not being respected when opening new workspaces. Users who configured a specific Python interpreter path would see a different Python version selected instead. The root cause is that the early return prevented `api.setEnvironment()` from ever being called, so the workspace environment was never actually set. When the extension later queried for the workspace environment, the `venvManager.get()` method found nothing in the workspace-to-environment map and fell back to `globalEnv`. Verified now the default is being used. <img width="681" height="214" alt="image" src="https://github.com/user-attachments/assets/19ec4e44-2f14-4331-9e6c-e7221475843a" /> Also fixed wrong field used for `sysPrefix`.
1 parent bff57a6 commit d84e05b

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/helpers.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ExtensionContext, extensions, QuickInputButtons, Uri, window, workspace } from 'vscode';
22
import { PythonEnvironment, PythonEnvironmentApi } from './api';
33
import { traceError, traceInfo, traceWarn } from './common/logging';
4-
import { normalizePath } from './common/utils/pathUtils';
54
import { isWindows } from './common/utils/platformUtils';
65
import { createTerminal, showInputBoxWithButtons } from './common/window.apis';
76
import { getConfiguration } from './common/workspace.apis';
@@ -271,10 +270,6 @@ export async function resolveDefaultInterpreter(
271270
try {
272271
const resolved: NativeEnvInfo = await nativeFinder.resolve(userSetdefaultInterpreter);
273272
if (resolved && resolved.executable) {
274-
if (normalizePath(resolved.executable) === normalizePath(userSetdefaultInterpreter)) {
275-
// no action required, the path is already correct
276-
return;
277-
}
278273
const resolvedEnv = await api.resolveEnvironment(Uri.file(resolved.executable));
279274
traceInfo(`[resolveDefaultInterpreter] API resolved environment: ${JSON.stringify(resolvedEnv)}`);
280275

@@ -294,7 +289,7 @@ export async function resolveDefaultInterpreter(
294289
version: resolved.version ?? '',
295290
displayPath: userSetdefaultInterpreter ?? '',
296291
environmentPath: userSetdefaultInterpreter ? Uri.file(userSetdefaultInterpreter) : Uri.file(''),
297-
sysPrefix: resolved.arch ?? '',
292+
sysPrefix: resolved.prefix ?? '',
298293
execInfo: {
299294
run: {
300295
executable: userSetdefaultInterpreter ?? '',

0 commit comments

Comments
 (0)