From a7e2b5a3b69c69388aaaa9d613bb8951cda1cbe6 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Thu, 3 Oct 2024 17:26:02 +1000 Subject: [PATCH] Avoid prefixing with home when unnecessary --- .../base/locators/common/nativePythonFinder.ts | 5 ++++- .../base/locators/lowLevel/customVirtualEnvLocator.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts b/src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts index a05fcb8b4de4..55c5ed9f83a3 100644 --- a/src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts +++ b/src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts @@ -422,7 +422,10 @@ function getCustomVirtualEnvDirs(): string[] { const venvFolders = getPythonSettingAndUntildify(VENVFOLDERS_SETTING_KEY) ?? []; const homeDir = getUserHomeDir(); if (homeDir) { - venvFolders.map((item) => path.join(homeDir, item)).forEach((d) => venvDirs.push(d)); + venvFolders + .map((item) => (item.startsWith(homeDir) ? item : path.join(homeDir, item))) + .forEach((d) => venvDirs.push(d)); + venvFolders.forEach((item) => venvDirs.push(untildify(item))); } return Array.from(new Set(venvDirs)); } diff --git a/src/client/pythonEnvironments/base/locators/lowLevel/customVirtualEnvLocator.ts b/src/client/pythonEnvironments/base/locators/lowLevel/customVirtualEnvLocator.ts index 4c6a05af4acc..6aa83bbc376b 100644 --- a/src/client/pythonEnvironments/base/locators/lowLevel/customVirtualEnvLocator.ts +++ b/src/client/pythonEnvironments/base/locators/lowLevel/customVirtualEnvLocator.ts @@ -41,7 +41,10 @@ async function getCustomVirtualEnvDirs(): Promise { const venvFolders = getPythonSetting(VENVFOLDERS_SETTING_KEY) ?? []; const homeDir = getUserHomeDir(); if (homeDir && (await pathExists(homeDir))) { - venvFolders.map((item) => path.join(homeDir, item)).forEach((d) => venvDirs.push(d)); + venvFolders + .map((item) => (item.startsWith(homeDir) ? item : path.join(homeDir, item))) + .forEach((d) => venvDirs.push(d)); + venvFolders.forEach((item) => venvDirs.push(untildify(item))); } return asyncFilter(uniq(venvDirs), pathExists); }