Skip to content

Commit bffed36

Browse files
wenytang-msCopilot
andcommitted
fix: always prepend separator when appending noConfigScripts to PATH
EnvironmentVariableCollection.append() performs a literal string concatenation and does not insert a path separator. The previous heuristic checked process.env.PATH on the extension host and skipped the separator when that PATH already ended with one. However, the PATH used by the integrated terminal can differ from the extension host's PATH, so this check could incorrectly drop the separator and glue the noConfigScripts directory onto the last entry of the user's PATH (e.g. C:\Program Files\jreleaser\c:\Users\...\noConfigScripts). Always prepend the separator. A trailing empty PATH entry (if the user's PATH already ended with one) is harmless on both Windows and POSIX shells. Fixes #1637 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0db5f15 commit bffed36

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/noConfigDebugInit.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ export async function registerNoConfigDebug(
9393
const noConfigScriptsDir = path.join(extPath, 'bundled', 'scripts', 'noConfigScripts');
9494
const pathSeparator = process.platform === 'win32' ? ';' : ':';
9595

96-
// Check if the current PATH already ends with a path separator to avoid double separators
97-
const currentPath = process.env.PATH || '';
98-
const needsSeparator = currentPath.length > 0 && !currentPath.endsWith(pathSeparator);
99-
const pathValueToAppend = needsSeparator ? `${pathSeparator}${noConfigScriptsDir}` : noConfigScriptsDir;
100-
101-
collection.append('PATH', pathValueToAppend);
96+
// EnvironmentVariableCollection.append() does literal string concatenation and does
97+
// not insert a separator. Always prepend one so we never glue our directory onto the
98+
// last entry of the user's PATH. We cannot rely on process.env.PATH ending with a
99+
// separator, since the terminal's PATH may differ from the extension host's PATH.
100+
// A trailing empty PATH entry (when PATH already ends with the separator) is harmless.
101+
collection.append('PATH', `${pathSeparator}${noConfigScriptsDir}`);
102102

103103
// create file system watcher for the debuggerAdapterEndpointFolder for when the communication port is written
104104
const fileSystemWatcher = vscode.workspace.createFileSystemWatcher(

0 commit comments

Comments
 (0)