diff --git a/news/2 Fixes/1192.md b/news/2 Fixes/1192.md new file mode 100644 index 000000000000..b97883d49d8a --- /dev/null +++ b/news/2 Fixes/1192.md @@ -0,0 +1 @@ +Reverted change that ended up considering symlinked interpreters as duplicate interpreter. diff --git a/src/client/interpreter/configuration/interpreterSelector.ts b/src/client/interpreter/configuration/interpreterSelector.ts index 1d116c7e2ab6..716dced6c0f7 100644 --- a/src/client/interpreter/configuration/interpreterSelector.ts +++ b/src/client/interpreter/configuration/interpreterSelector.ts @@ -76,10 +76,9 @@ export class InterpreterSelector implements IInterpreterSelector { private async removeDuplicates(interpreters: PythonInterpreter[]): Promise { const result: PythonInterpreter[] = []; - await Promise.all(interpreters.map(async item => item.realPath = await this.fileSystem.getRealPathAsync(item.path))); interpreters.forEach(x => { if (result.findIndex(a => a.displayName === x.displayName - && a.type === x.type && this.fileSystem.arePathsSame(a.realPath!, x.realPath!)) < 0) { + && a.type === x.type && this.fileSystem.arePathsSame(path.dirname(a.path), path.dirname(x.path))) < 0) { result.push(x); } }); diff --git a/src/client/interpreter/contracts.ts b/src/client/interpreter/contracts.ts index d2540595fa96..9029a05dbb4e 100644 --- a/src/client/interpreter/contracts.ts +++ b/src/client/interpreter/contracts.ts @@ -67,7 +67,6 @@ export type PythonInterpreter = { envName?: string; envPath?: string; cachedEntry?: boolean; - realPath?: string; }; export type WorkspacePythonPath = { diff --git a/src/test/configuration/interpreterSelector.test.ts b/src/test/configuration/interpreterSelector.test.ts index b53dd61c79d2..5dbb7f7bd70d 100644 --- a/src/test/configuration/interpreterSelector.test.ts +++ b/src/test/configuration/interpreterSelector.test.ts @@ -15,7 +15,7 @@ import { IServiceContainer } from '../../client/ioc/types'; class InterpreterQuickPickItem implements IInterpreterQuickPickItem { public path: string; public label: string; - public description: string; + public description!: string; public detail?: string; constructor(l: string, p: string) { this.path = p; @@ -24,7 +24,7 @@ class InterpreterQuickPickItem implements IInterpreterQuickPickItem { } // tslint:disable-next-line:max-func-body-length -suite('Intepreters - selector', () => { +suite('Interpreters - selector', () => { let serviceContainer: IServiceContainer; let workspace: TypeMoq.IMock; let appShell: TypeMoq.IMock; @@ -65,14 +65,14 @@ suite('Intepreters - selector', () => { test('Suggestions', async () => { const initial: PythonInterpreter[] = [ - { displayName: '1', path: 'path1', type: InterpreterType.Unknown }, - { displayName: '2', path: 'path1', type: InterpreterType.Unknown }, - { displayName: '1', path: 'path1', type: InterpreterType.Unknown }, - { displayName: '2', path: 'path2', type: InterpreterType.Unknown }, - { displayName: '2', path: 'path2', type: InterpreterType.Unknown }, - { displayName: '2 (virtualenv)', path: 'path2', type: InterpreterType.VirtualEnv }, - { displayName: '3', path: 'path2', type: InterpreterType.Unknown }, - { displayName: '4', path: 'path4', type: InterpreterType.Conda } + { displayName: '1', path: 'c:/path1/path1', type: InterpreterType.Unknown }, + { displayName: '2', path: 'c:/path1/path1', type: InterpreterType.Unknown }, + { displayName: '1', path: 'c:/path1/path1', type: InterpreterType.Unknown }, + { displayName: '2', path: 'c:/path2/path2', type: InterpreterType.Unknown }, + { displayName: '2', path: 'c:/path2/path2', type: InterpreterType.Unknown }, + { displayName: '2 (virtualenv)', path: 'c:/path2/path2', type: InterpreterType.VirtualEnv }, + { displayName: '3', path: 'c:/path2/path2', type: InterpreterType.Unknown }, + { displayName: '4', path: 'c:/path4/path4', type: InterpreterType.Conda } ]; interpreterService .setup(x => x.getInterpreters(TypeMoq.It.isAny())) @@ -82,12 +82,12 @@ suite('Intepreters - selector', () => { const actual = await selector.getSuggestions(); const expected: InterpreterQuickPickItem[] = [ - new InterpreterQuickPickItem('1', 'path1'), - new InterpreterQuickPickItem('2', 'path1'), - new InterpreterQuickPickItem('2', 'path2'), - new InterpreterQuickPickItem('2 (virtualenv)', 'path2'), - new InterpreterQuickPickItem('3', 'path2'), - new InterpreterQuickPickItem('4', 'path4') + new InterpreterQuickPickItem('1', 'c:/path1/path1'), + new InterpreterQuickPickItem('2', 'c:/path1/path1'), + new InterpreterQuickPickItem('2', 'c:/path2/path2'), + new InterpreterQuickPickItem('2 (virtualenv)', 'c:/path2/path2'), + new InterpreterQuickPickItem('3', 'c:/path2/path2'), + new InterpreterQuickPickItem('4', 'c:/path4/path4') ]; assert.equal(actual.length, expected.length, 'Suggestion lengths are different.');