From 43f5f2f1725bcec4b93b05ed2558f2c59f7c042d Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Mon, 1 Oct 2018 18:28:12 -0700 Subject: [PATCH 1/2] Prefix relative paths with './' --- .../configuration/services/workspaceFolderUpdaterService.ts | 2 +- .../configuration/services/workspaceUpdaterService.ts | 2 +- src/test/interpreters/pythonPathUpdater.test.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/interpreter/configuration/services/workspaceFolderUpdaterService.ts b/src/client/interpreter/configuration/services/workspaceFolderUpdaterService.ts index 03c531f8dce9..922c8b0c9f87 100644 --- a/src/client/interpreter/configuration/services/workspaceFolderUpdaterService.ts +++ b/src/client/interpreter/configuration/services/workspaceFolderUpdaterService.ts @@ -14,7 +14,7 @@ export class WorkspaceFolderPythonPathUpdaterService implements IPythonPathUpdat return; } if (pythonPath.startsWith(this.workspaceFolder.fsPath)) { - pythonPath = path.relative(this.workspaceFolder.fsPath, pythonPath); + pythonPath = path.join('.', path.relative(this.workspaceFolder.fsPath, pythonPath)); } await pythonConfig.update('pythonPath', pythonPath, ConfigurationTarget.WorkspaceFolder); } diff --git a/src/client/interpreter/configuration/services/workspaceUpdaterService.ts b/src/client/interpreter/configuration/services/workspaceUpdaterService.ts index 81624581d2f2..b97504a35654 100644 --- a/src/client/interpreter/configuration/services/workspaceUpdaterService.ts +++ b/src/client/interpreter/configuration/services/workspaceUpdaterService.ts @@ -14,7 +14,7 @@ export class WorkspacePythonPathUpdaterService implements IPythonPathUpdaterServ return; } if (pythonPath.startsWith(this.workspace.fsPath)) { - pythonPath = path.relative(this.workspace.fsPath, pythonPath); + pythonPath = path.join('.', path.relative(this.workspace.fsPath, pythonPath)); } await pythonConfig.update('pythonPath', pythonPath, false); } diff --git a/src/test/interpreters/pythonPathUpdater.test.ts b/src/test/interpreters/pythonPathUpdater.test.ts index 35657bf82703..dc2e9bcb78f6 100644 --- a/src/test/interpreters/pythonPathUpdater.test.ts +++ b/src/test/interpreters/pythonPathUpdater.test.ts @@ -80,7 +80,7 @@ suite('Python Path Settings Updater', () => { const workspaceFolder = Uri.file(workspaceFolderPath); const updater = updaterServiceFactory.getWorkspaceFolderPythonPathConfigurationService(workspaceFolder); const pythonPath = Uri.file(path.join(workspaceFolderPath, 'env', 'bin', 'python')).fsPath; - const expectedPythonPath = path.join('env', 'bin', 'python'); + const expectedPythonPath = path.join('.', 'env', 'bin', 'python'); const workspaceConfig = setupConfigProvider(workspaceFolder); workspaceConfig.setup(w => w.inspect(TypeMoq.It.isValue('pythonPath'))).returns(() => undefined); @@ -120,7 +120,7 @@ suite('Python Path Settings Updater', () => { const workspaceFolder = Uri.file(workspaceFolderPath); const updater = updaterServiceFactory.getWorkspacePythonPathConfigurationService(workspaceFolder); const pythonPath = Uri.file(path.join(workspaceFolderPath, 'env', 'bin', 'python')).fsPath; - const expectedPythonPath = path.join('env', 'bin', 'python'); + const expectedPythonPath = path.join('.', 'env', 'bin', 'python'); const workspaceConfig = setupConfigProvider(workspaceFolder); workspaceConfig.setup(w => w.inspect(TypeMoq.It.isValue('pythonPath'))).returns(() => undefined); From 568355a33bd11c8c0f2a15a62e18b8f7035a94f1 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 2 Oct 2018 07:45:05 -0700 Subject: [PATCH 2/2] Ensure relative path is prefixed with ./ --- news/2 Fixes/2744.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/2 Fixes/2744.md diff --git a/news/2 Fixes/2744.md b/news/2 Fixes/2744.md new file mode 100644 index 000000000000..28c59ff60495 --- /dev/null +++ b/news/2 Fixes/2744.md @@ -0,0 +1 @@ +Ensure relative paths to python interpreters in `python.pythonPath` of `settings.json` are prefixed with `./` or `.\\` (depending on the OS).