From a6e8287882f717080170a1655b94978d46dc09b5 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 18 Mar 2021 15:54:04 -0700 Subject: [PATCH] Fix `python.poetryPath` setting for installer on Windows --- news/2 Fixes/9672.md | 1 + src/client/common/installer/poetryInstaller.ts | 2 +- .../common/installer/poetryInstaller.unit.test.ts | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 news/2 Fixes/9672.md diff --git a/news/2 Fixes/9672.md b/news/2 Fixes/9672.md new file mode 100644 index 000000000000..81e2085e0df2 --- /dev/null +++ b/news/2 Fixes/9672.md @@ -0,0 +1 @@ +Fix `python.poetryPath` setting for installer on Windows. diff --git a/src/client/common/installer/poetryInstaller.ts b/src/client/common/installer/poetryInstaller.ts index b8a7f750e256..ad1eddfd76ed 100644 --- a/src/client/common/installer/poetryInstaller.ts +++ b/src/client/common/installer/poetryInstaller.ts @@ -57,7 +57,7 @@ export class PoetryInstaller extends ModuleInstaller { try { const processService = await this.processFactory.create(workfolder); const execPath = this.configurationService.getSettings(workfolder).poetryPath; - const result = await processService.exec(execPath, ['list'], { cwd: workfolder.fsPath }); + const result = await processService.shellExec(`${execPath} env list`, { cwd: workfolder.fsPath }); return result && (result.stderr || '').trim().length === 0; } catch (error) { traceError(`${poetryFile} exists but Poetry not found`, error); diff --git a/src/test/common/installer/poetryInstaller.unit.test.ts b/src/test/common/installer/poetryInstaller.unit.test.ts index 086067f61b45..1d40b634f9a0 100644 --- a/src/test/common/installer/poetryInstaller.unit.test.ts +++ b/src/test/common/installer/poetryInstaller.unit.test.ts @@ -89,7 +89,7 @@ suite('Module Installer - Poetry', () => { when(workspaceService.getWorkspaceFolder(anything())).thenReturn({ uri, name: '', index: 0 }); when(fileSystem.fileExists(anything())).thenResolve(true); when(processServiceFactory.create(anything())).thenResolve(instance(processService)); - when(processService.exec(anything(), anything(), anything())).thenResolve({ stderr: 'Kaboom', stdout: '' }); + when(processService.shellExec(anything(), anything())).thenResolve({ stderr: 'Kaboom', stdout: '' }); const supported = await poetryInstaller.isSupported(Uri.file(__filename)); @@ -105,7 +105,7 @@ suite('Module Installer - Poetry', () => { when(workspaceService.getWorkspaceFolder(anything())).thenReturn({ uri, name: '', index: 0 }); when(fileSystem.fileExists(anything())).thenResolve(true); when(processServiceFactory.create(anything())).thenResolve(instance(processService)); - when(processService.exec(anything(), anything(), anything())).thenReject(new Error('Kaboom')); + when(processService.shellExec(anything(), anything())).thenReject(new Error('Kaboom')); const supported = await poetryInstaller.isSupported(Uri.file(__filename)); @@ -121,7 +121,7 @@ suite('Module Installer - Poetry', () => { when(workspaceService.getWorkspaceFolder(anything())).thenReturn({ uri, name: '', index: 0 }); when(fileSystem.fileExists(anything())).thenResolve(true); when(processServiceFactory.create(uri)).thenResolve(instance(processService)); - when(processService.exec('poetry path', anything(), anything())).thenResolve({ stderr: '', stdout: '' }); + when(processService.shellExec('poetry path', anything())).thenResolve({ stderr: '', stdout: '' }); const supported = await poetryInstaller.isSupported(Uri.file(__filename)); @@ -147,6 +147,9 @@ suite('Module Installer - Poetry', () => { const info = await poetryInstaller.getExecutionInfo('black', uri); - assert.deepEqual(info, { args: ['add', '--dev', 'black', '--allow-prereleases'], execPath: 'poetry path' }); + assert.deepEqual(info, { + args: ['add', '--dev', 'black', '--allow-prereleases'], + execPath: 'poetry path', + }); }); });