Skip to content

bug: fix path resolution to use resolved environment directly from settings#1229

Closed
eleanorjboyd wants to merge 1 commit intomicrosoft:mainfrom
eleanorjboyd:static-bear
Closed

bug: fix path resolution to use resolved environment directly from settings#1229
eleanorjboyd wants to merge 1 commit intomicrosoft:mainfrom
eleanorjboyd:static-bear

Conversation

@eleanorjboyd
Copy link
Member

No description provided.

@eleanorjboyd eleanorjboyd requested a review from Copilot February 13, 2026 16:19
@eleanorjboyd eleanorjboyd self-assigned this Feb 13, 2026
@eleanorjboyd eleanorjboyd added the bug Issue identified by VS Code Team member as probable bug label Feb 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts interpreter selection when resolving python.defaultInterpreterPath, switching from constructing a wrapper PythonEnvironment to reusing the PythonEnvironment returned by api.resolveEnvironment() so the selected environment uses the canonical environment identifier.

Changes:

  • Removed the custom “defaultInterpreterPath:*” wrapper environment construction.
  • Return the resolvedEnv directly (and add verbose logging including the resolved environment ID).

Comment on lines +394 to +399
// 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' };
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant