Skip to content

Commit cc86d10

Browse files
authored
Ensure python path is not set if already set in user settings (#369)
disable autosetting interpreter if already set
1 parent a015bf9 commit cc86d10

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/client/interpreter/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export class InterpreterManager implements Disposable {
4747
const interpreters = await this.interpreterProvider.getInterpreters(activeWorkspace.folderUri);
4848
const workspacePathUpper = activeWorkspace.folderUri.fsPath.toUpperCase();
4949
const interpretersInWorkspace = interpreters.filter(interpreter => interpreter.path.toUpperCase().startsWith(workspacePathUpper));
50-
if (interpretersInWorkspace.length !== 1) {
50+
// Always pick the first available one.
51+
if (interpretersInWorkspace.length === 0) {
5152
return;
5253
}
5354

@@ -73,6 +74,10 @@ export class InterpreterManager implements Disposable {
7374
}
7475
const pythonConfig = workspace.getConfiguration('python', activeWorkspace.folderUri);
7576
const pythonPathInConfig = pythonConfig.inspect<string>('pythonPath');
77+
// If we have a value in user settings, then don't auto set the interpreter path.
78+
if (pythonPathInConfig && pythonPathInConfig!.globalValue !== undefined && pythonPathInConfig!.globalValue !== 'python') {
79+
return false;
80+
}
7681
if (activeWorkspace.configTarget === ConfigurationTarget.Workspace) {
7782
return pythonPathInConfig.workspaceValue === undefined || pythonPathInConfig.workspaceValue === 'python';
7883
}

0 commit comments

Comments
 (0)