@@ -95,7 +95,11 @@ import { collectEnvironmentInfo, getEnvManagerAndPackageManagerConfigLevels, run
9595import { EnvironmentManagers , ProjectCreators , PythonProjectManager } from './internal.api' ;
9696import { registerSystemPythonFeatures } from './managers/builtin/main' ;
9797import { SysPythonManager } from './managers/builtin/sysPythonManager' ;
98- import { createNativePythonFinder , NativePythonFinder } from './managers/common/nativePythonFinder' ;
98+ import {
99+ createNativePythonFinder ,
100+ NativePythonFinder ,
101+ PetBinaryNotFoundError ,
102+ } from './managers/common/nativePythonFinder' ;
99103import { IDisposable } from './managers/common/types' ;
100104import { registerCondaFeatures } from './managers/conda/main' ;
101105import { registerPipenvFeatures } from './managers/pipenv/main' ;
@@ -530,21 +534,32 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
530534 traceError ( 'Failed to start Python finder (pet):' , error ) ;
531535
532536 const errnoError = error as NodeJS . ErrnoException ;
533- // Plain Error (no .code) = binary not found by getNativePythonToolsPath.
534- // Errno error (has .code) = spawn failed (ENOENT, EACCES, EPERM, etc.).
535- const reason = errnoError . code ? 'spawn_failed' : 'binary_not_found' ;
537+ // PetBinaryNotFoundError = file missing; errno .code = OS spawn failure; anything else = unknown.
538+ const reason =
539+ error instanceof PetBinaryNotFoundError
540+ ? 'binary_not_found'
541+ : errnoError . code
542+ ? 'spawn_failed'
543+ : 'unknown' ;
536544 sendTelemetryEvent ( EventNames . PET_START_FAILED , undefined , {
537545 errorCode : errnoError . code ?? 'UNKNOWN' ,
538546 reason,
539547 platform : process . platform ,
540548 arch : process . arch ,
541549 } ) ;
542550
543- window . showErrorMessage (
544- l10n . t (
545- 'Python Environments: Failed to start the Python finder. Some features may not work correctly. Check the Output panel for details.' ,
546- ) ,
551+ const openOutput = l10n . t ( 'Open Output' ) ;
552+ const openSettings = l10n . t ( 'Open Settings' ) ;
553+ const choice = await window . showErrorMessage (
554+ l10n . t ( 'Python Environments: Failed to start the Python finder. Some features may not work correctly.' ) ,
555+ openOutput ,
556+ openSettings ,
547557 ) ;
558+ if ( choice === openOutput ) {
559+ outputChannel . show ( ) ;
560+ } else if ( choice === openSettings ) {
561+ await commands . executeCommand ( 'workbench.action.openSettings' , 'python.defaultInterpreterPath' ) ;
562+ }
548563 return ;
549564 }
550565
0 commit comments