Skip to content

Commit 08417ad

Browse files
author
Kartik Raj
authored
Do not cache result if running an interpreter fails (#20178)
For microsoft#20147
1 parent 8e5ec71 commit 08417ad

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/client/common/variables/environmentVariablesProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { inject, injectable, optional } from 'inversify';
55
import path from 'path';
66
import { ConfigurationChangeEvent, Disposable, Event, EventEmitter, FileSystemWatcher, Uri } from 'vscode';
7-
import { traceError } from '../../logging';
7+
import { traceError, traceVerbose } from '../../logging';
88
import { sendFileCreationTelemetry } from '../../telemetry/envFileTelemetry';
99
import { IWorkspaceService } from '../application/types';
1010
import { PythonSettings } from '../configSettings';
@@ -61,6 +61,7 @@ export class EnvironmentVariablesProvider implements IEnvironmentVariablesProvid
6161
}
6262
const vars = await this._getEnvironmentVariables(resource);
6363
this.setCachedEnvironmentVariables(resource, vars);
64+
traceVerbose('Dump environment variables', JSON.stringify(vars, null, 4));
6465
return vars;
6566
}
6667

src/client/pythonEnvironments/base/info/environmentInfoService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ class EnvironmentInfoService implements IEnvironmentInfoService {
102102
this._getEnvironmentInfo(env, priority)
103103
.then((r) => {
104104
deferred.resolve(r);
105+
if (r === undefined) {
106+
this.cache.delete(normCasePath(interpreterPath));
107+
}
105108
})
106109
.catch((ex) => {
107110
deferred.reject(ex);

src/client/pythonEnvironments/common/environmentManagers/conda.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export class Conda {
435435
// eslint-disable-next-line class-methods-use-this
436436
private async getInfoImpl(command: string): Promise<CondaInfo> {
437437
const result = await exec(command, ['info', '--json'], { timeout: CONDA_GENERAL_TIMEOUT });
438-
traceVerbose(`conda info --json: ${result.stdout}`);
438+
traceVerbose(`${command} info --json: ${result.stdout}`);
439439
return JSON.parse(result.stdout);
440440
}
441441

0 commit comments

Comments
 (0)