diff --git a/src/managers/builtin/utils.ts b/src/managers/builtin/utils.ts index da2aa2ad..591a5dd7 100644 --- a/src/managers/builtin/utils.ts +++ b/src/managers/builtin/utils.ts @@ -10,6 +10,7 @@ import { } from '../../api'; import { showErrorMessageWithLogs } from '../../common/errors/utils'; import { SysManagerStrings } from '../../common/localize'; +import { traceVerbose } from '../../common/logging'; import { withProgress } from '../../common/window.apis'; import { isNativeEnvInfo, @@ -299,11 +300,16 @@ export async function resolveSystemPythonEnvironmentPath( api: PythonEnvironmentApi, manager: EnvironmentManager, ): Promise { - const resolved = await nativeFinder.resolve(fsPath); + try { + const resolved = await nativeFinder.resolve(fsPath); - // This is supposed to handle a python interpreter as long as we know some basic things about it - if (resolved.executable && resolved.version && resolved.prefix) { - const envInfo = getPythonInfo(resolved); - return api.createPythonEnvironmentItem(envInfo, manager); + // This is supposed to handle a python interpreter as long as we know some basic things about it + if (resolved.executable && resolved.version && resolved.prefix) { + const envInfo = getPythonInfo(resolved); + return api.createPythonEnvironmentItem(envInfo, manager); + } + } catch (ex) { + traceVerbose(`Failed to resolve env "${fsPath}": ${ex}`); } + return undefined; } diff --git a/src/managers/builtin/venvUtils.ts b/src/managers/builtin/venvUtils.ts index 54137832..522b6b1a 100644 --- a/src/managers/builtin/venvUtils.ts +++ b/src/managers/builtin/venvUtils.ts @@ -5,7 +5,7 @@ import { l10n, LogOutputChannel, ProgressLocation, QuickPickItem, QuickPickItemK import { EnvironmentManager, PythonEnvironment, PythonEnvironmentApi, PythonEnvironmentInfo } from '../../api'; import { ENVS_EXTENSION_ID } from '../../common/constants'; import { Common, VenvManagerStrings } from '../../common/localize'; -import { traceInfo } from '../../common/logging'; +import { traceInfo, traceVerbose } from '../../common/logging'; import { getWorkspacePersistentState } from '../../common/persistentState'; import { EventNames } from '../../common/telemetry/constants'; import { sendTelemetryEvent } from '../../common/telemetry/sender'; @@ -581,15 +581,19 @@ export async function resolveVenvPythonEnvironmentPath( manager: EnvironmentManager, baseManager: EnvironmentManager, ): Promise { - const resolved = await nativeFinder.resolve(fsPath); - - if ( - resolved.kind === NativePythonEnvironmentKind.venv || - resolved.kind === NativePythonEnvironmentKind.venvUv || - resolved.kind === NativePythonEnvironmentKind.uvWorkspace - ) { - const envInfo = await getPythonInfo(resolved); - return api.createPythonEnvironmentItem(envInfo, manager); + try { + const resolved = await nativeFinder.resolve(fsPath); + + if ( + resolved.kind === NativePythonEnvironmentKind.venv || + resolved.kind === NativePythonEnvironmentKind.venvUv || + resolved.kind === NativePythonEnvironmentKind.uvWorkspace + ) { + const envInfo = await getPythonInfo(resolved); + return api.createPythonEnvironmentItem(envInfo, manager); + } + } catch (ex) { + traceVerbose(`Failed to resolve venv env "${fsPath}": ${ex}`); } return resolveSystemPythonEnvironmentPath(fsPath, nativeFinder, api, baseManager); diff --git a/src/managers/pipenv/pipenvUtils.ts b/src/managers/pipenv/pipenvUtils.ts index 79a41640..659cbff3 100644 --- a/src/managers/pipenv/pipenvUtils.ts +++ b/src/managers/pipenv/pipenvUtils.ts @@ -12,7 +12,7 @@ import { PythonEnvironmentInfo, } from '../../api'; import { ENVS_EXTENSION_ID } from '../../common/constants'; -import { traceError, traceInfo } from '../../common/logging'; +import { traceError, traceInfo, traceVerbose } from '../../common/logging'; import { getWorkspacePersistentState } from '../../common/persistentState'; import { untildify } from '../../common/utils/pathUtils'; import { getSettingWorkspaceScope } from '../../features/settings/settingHelpers'; @@ -222,12 +222,16 @@ export async function resolvePipenvPath( api: PythonEnvironmentApi, manager: EnvironmentManager, ): Promise { - const resolved = await nativeFinder.resolve(fsPath); + try { + const resolved = await nativeFinder.resolve(fsPath); - // Resolve pipenv environments even if the pipenv CLI is not found. - // This allows proper environment identification for read-only scenarios. - if (resolved.kind === NativePythonEnvironmentKind.pipenv) { - return await nativeToPythonEnv(resolved, api, manager); + // Resolve pipenv environments even if the pipenv CLI is not found. + // This allows proper environment identification for read-only scenarios. + if (resolved.kind === NativePythonEnvironmentKind.pipenv) { + return await nativeToPythonEnv(resolved, api, manager); + } + } catch (ex) { + traceVerbose(`Failed to resolve pipenv env "${fsPath}": ${ex}`); } return undefined;