diff --git a/src/client/interpreter/interpreterService.ts b/src/client/interpreter/interpreterService.ts index 9321071c4ad9..a59c18164e16 100644 --- a/src/client/interpreter/interpreterService.ts +++ b/src/client/interpreter/interpreterService.ts @@ -160,7 +160,7 @@ export class InterpreterService implements Disposable, IInterpreterService { environments .filter((item) => !item.displayName) .map(async (item) => { - item.displayName = await this.getDisplayName(item, resource); + item.displayName = await this.getDisplayName(item, resource, options?.ignoreCache); // Keep information up to date with latest details. if (!item.cachedEntry) { this.updateCachedInterpreterInformation(item, resource).ignoreErrors(); @@ -277,9 +277,13 @@ export class InterpreterService implements Disposable, IInterpreterService { * @returns {string} * @memberof InterpreterService */ - public async getDisplayName(info: Partial, resource?: Uri): Promise { + public async getDisplayName( + info: Partial, + resource?: Uri, + ignoreCache = false, + ): Promise { // faster than calculating file has again and again, only when dealing with cached items. - if (!info.cachedEntry && info.path && this.inMemoryCacheOfDisplayNames.has(info.path)) { + if (!ignoreCache && !info.cachedEntry && info.path && this.inMemoryCacheOfDisplayNames.has(info.path)) { return this.inMemoryCacheOfDisplayNames.get(info.path)!; } const interpreterKey = info.path ?? ''; @@ -289,7 +293,7 @@ export class InterpreterService implements Disposable, IInterpreterService { EXPIRY_DURATION, ); - if (store.value && store.value.hash === interpreterKey && store.value.displayName) { + if (!ignoreCache && store.value && store.value.hash === interpreterKey && store.value.displayName) { this.inMemoryCacheOfDisplayNames.set(info.path!, store.value.displayName); return store.value.displayName; } diff --git a/src/client/pythonEnvironments/legacyIOC.ts b/src/client/pythonEnvironments/legacyIOC.ts index 5b08c04a0258..44a864a8586d 100644 --- a/src/client/pythonEnvironments/legacyIOC.ts +++ b/src/client/pythonEnvironments/legacyIOC.ts @@ -156,6 +156,7 @@ class ComponentAdapter implements IComponentAdapter, IExtensionSingleActivationS const query = { kinds: e.kind ? [e.kind] : undefined, searchLocations: e.searchLocation ? { roots: [e.searchLocation] } : undefined, + ignoreCache: true, }; // Trigger a background refresh of the environments. getEnvs(this.api.iterEnvs(query)).ignoreErrors(); diff --git a/src/test/interpreters/interpreterService.unit.test.ts b/src/test/interpreters/interpreterService.unit.test.ts index 9d919e4b8111..421e287e5e06 100644 --- a/src/test/interpreters/interpreterService.unit.test.ts +++ b/src/test/interpreters/interpreterService.unit.test.ts @@ -579,6 +579,7 @@ suite('Interpreters service', () => { const displayName = await service.getDisplayName( interpreterInfo, resource, + true, ); expect(displayName).to.equal(expectedDisplayName); });