Skip to content
Closed
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
24 changes: 4 additions & 20 deletions src/features/interpreterSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,28 +391,12 @@ async function tryResolveInterpreterPath(
}

if (manager && resolvedEnv) {
// Create a wrapper environment that uses the user's specified path
const newEnv: PythonEnvironment = {
envId: {
id: `defaultInterpreterPath:${interpreterPath}`,
managerId: manager.id,
},
name: 'defaultInterpreterPath: ' + (resolved.version ?? ''),
displayName: 'defaultInterpreterPath: ' + (resolved.version ?? ''),
version: resolved.version ?? '',
displayPath: interpreterPath,
environmentPath: Uri.file(interpreterPath),
sysPrefix: resolved.prefix ?? '',
execInfo: {
run: {
executable: interpreterPath,
},
},
};
// Use the resolved environment directly - it has the canonical ID format
// The 'source' field tracks that this came from defaultInterpreterPath setting
traceVerbose(
`[tryResolveInterpreterPath] Resolved '${interpreterPath}' to ${resolved.executable} (${resolved.version})`,
`[tryResolveInterpreterPath] Resolved '${interpreterPath}' to ${resolved.executable} (${resolved.version}) with ID ${resolvedEnv.envId.id}`,
);
return { manager, environment: newEnv, source: 'defaultInterpreterPath' };
return { manager, environment: resolvedEnv, source: 'defaultInterpreterPath' };
Comment on lines +394 to +399
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning resolvedEnv directly changes behavior when nativeFinder.resolve() canonicalizes/follows symlinks: the selected environment will now expose the resolved executable path (e.g., Homebrew) rather than the user-configured defaultInterpreterPath value. This currently contradicts the existing unit test should use original user path even when nativeFinder resolves to a different executable and will fail. Either update the tests/expected behavior, or keep the canonical envId from resolvedEnv but override the path fields (displayPath/environmentPath/execInfo.run.executable) to preserve the user-configured path.

See below for a potential fix:

                // Use the resolved environment's canonical ID and metadata, but preserve the user-configured
                // interpreterPath for all user-facing path fields. This matches the expectation that
                // defaultInterpreterPath remains visible even if nativeFinder.resolve() canonicalizes/follows symlinks.
                const selectedEnv: PythonEnvironment = {
                    ...resolvedEnv,
                    displayPath: interpreterPath,
                    environmentPath: interpreterPath,
                    execInfo:
                        resolvedEnv.execInfo && resolvedEnv.execInfo.run
                            ? {
                                  ...resolvedEnv.execInfo,
                                  run: {
                                      ...resolvedEnv.execInfo.run,
                                      executable: interpreterPath,
                                  },
                              }
                            : resolvedEnv.execInfo,
                };
                traceVerbose(
                    `[tryResolveInterpreterPath] Resolved '${interpreterPath}' to ${resolved.executable} (${resolved.version}) with ID ${resolvedEnv.envId.id}`,
                );
                return { manager, environment: selectedEnv, source: 'defaultInterpreterPath' };

Copilot uses AI. Check for mistakes.
}
}
traceVerbose(
Expand Down
Loading