diff --git a/src/client/pythonEnvironments/index.ts b/src/client/pythonEnvironments/index.ts index 91064bb675991..373812b33061d 100644 --- a/src/client/pythonEnvironments/index.ts +++ b/src/client/pythonEnvironments/index.ts @@ -60,7 +60,9 @@ export async function initialize(ext: ExtensionState): Promise { if (shouldUseNativeLocator()) { const finder = getNativePythonFinder(); + ext.disposables.push(finder); const api = createNativeEnvironmentsApi(finder); + ext.disposables.push(api); registerNewDiscoveryForIOC( // These are what get wrapped in the legacy adapter. ext.legacyIOC.serviceManager, diff --git a/src/client/pythonEnvironments/nativeAPI.ts b/src/client/pythonEnvironments/nativeAPI.ts index 8f12addabfb4a..fef76987546a9 100644 --- a/src/client/pythonEnvironments/nativeAPI.ts +++ b/src/client/pythonEnvironments/nativeAPI.ts @@ -334,7 +334,7 @@ class NativePythonEnvironments implements IDiscoveryAPI, Disposable { } } -export function createNativeEnvironmentsApi(finder: NativePythonFinder): IDiscoveryAPI { +export function createNativeEnvironmentsApi(finder: NativePythonFinder): IDiscoveryAPI & Disposable { const native = new NativePythonEnvironments(finder); native.triggerRefresh().ignoreErrors(); return native;