From 35215a7fb619258be69e9469337c543df4fb93e5 Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Fri, 16 Jun 2023 09:08:51 +0800 Subject: [PATCH] Prevent duplicate binPath in PATH environment variable - Check if binPath is already in PATH before adding it. - Add binPath to PATH only if it's not already present. - Log a message when binPath is added to PATH. --- src/contributes/commandsBase.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/contributes/commandsBase.ts b/src/contributes/commandsBase.ts index 85b23d9..41b22af 100644 --- a/src/contributes/commandsBase.ts +++ b/src/contributes/commandsBase.ts @@ -62,5 +62,8 @@ export function getPipxEnvironmentPath(pythonCommand: string): string | null { function updateEnvironmentPath(binPath: string): void { // Add BIN path to PATH - process.env.PATH = `${binPath}:${process.env.PATH}`; + if (process.env.PATH?.indexOf(binPath) === undefined) { + process.env.PATH = `${binPath}:${process.env.PATH}`; + logger.channel()?.info(`Added ${binPath} to PATH.`); + } } \ No newline at end of file