Skip to content

Commit 05e9a5b

Browse files
Avoid prefixing with home when unnecessary (#24232)
Fixes #24133 Co-authored-by: Don Jayamanne <don.jayamanne@outlook.com>
1 parent 7455cd5 commit 05e9a5b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,10 @@ function getCustomVirtualEnvDirs(): string[] {
422422
const venvFolders = getPythonSettingAndUntildify<string[]>(VENVFOLDERS_SETTING_KEY) ?? [];
423423
const homeDir = getUserHomeDir();
424424
if (homeDir) {
425-
venvFolders.map((item) => path.join(homeDir, item)).forEach((d) => venvDirs.push(d));
425+
venvFolders
426+
.map((item) => (item.startsWith(homeDir) ? item : path.join(homeDir, item)))
427+
.forEach((d) => venvDirs.push(d));
428+
venvFolders.forEach((item) => venvDirs.push(untildify(item)));
426429
}
427430
return Array.from(new Set(venvDirs));
428431
}

src/client/pythonEnvironments/base/locators/lowLevel/customVirtualEnvLocator.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ async function getCustomVirtualEnvDirs(): Promise<string[]> {
4141
const venvFolders = getPythonSetting<string[]>(VENVFOLDERS_SETTING_KEY) ?? [];
4242
const homeDir = getUserHomeDir();
4343
if (homeDir && (await pathExists(homeDir))) {
44-
venvFolders.map((item) => path.join(homeDir, item)).forEach((d) => venvDirs.push(d));
44+
venvFolders
45+
.map((item) => (item.startsWith(homeDir) ? item : path.join(homeDir, item)))
46+
.forEach((d) => venvDirs.push(d));
47+
venvFolders.forEach((item) => venvDirs.push(untildify(item)));
4548
}
4649
return asyncFilter(uniq(venvDirs), pathExists);
4750
}

0 commit comments

Comments
 (0)