Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/services/process-executor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,20 @@ function setUpProcess(options: ProcessExecutionOptions) {
*/
function buildChildEnvironment(options: ProcessExecutionOptions) {
if (SHOULD_HIDE_PRIVATE_NODEJS) {
let privateNodeDir = path.dirname(process.execPath).replace(/\/bin$/, '');
privateNodeDir=privateNodeDir.endsWith('/') ? privateNodeDir : `${privateNodeDir}/`
let privateNodeDir = path.dirname(process.execPath).replace(/[/\\]bin$/, '');
// Normalize to forward slashes for consistent matching (Git Bash on Windows uses POSIX paths)
const normalizedPrivateDir = privateNodeDir.replace(/\\/g, '/');
const currentPath = (options.env || process.env).PATH || '';
// Support both ":" (POSIX/Git Bash) and ";" (native Windows) delimiters
const delimiter = currentPath.includes(';') ? ';' : ':';
const cleanedPath = currentPath
.split(path.delimiter)
.filter(p => !p.startsWith(privateNodeDir))
.join(path.delimiter);
.split(delimiter)
.filter(p => {
const normalizedEntry = p.replace(/\\/g, '/');
return !normalizedEntry.startsWith(normalizedPrivateDir + '/') &&
normalizedEntry !== normalizedPrivateDir;
})
.join(delimiter);
return { ...options.env, PATH: cleanedPath };
}

Expand Down
Loading