From 298bacfcb3d3495dfb085a57ec76d6ba352a74eb Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Thu, 18 Sep 2025 10:04:28 +0200 Subject: [PATCH] fix: remove duplicate entries in PATH Otherwise the environment variable may be longer than 128KiB, which Linux does not allow (spawn fails with E2BIG). --- lib/spawn.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/spawn.js b/lib/spawn.js index 30e5b81..212883c 100644 --- a/lib/spawn.js +++ b/lib/spawn.js @@ -33,6 +33,14 @@ function spawn (cmd, args, options, log) { const cmdWillOutput = willCmdOutput(options && options.stdio) if (cmdWillOutput) startRunning(log) + + if (options.env["PATH"]) { + const fullPath = options.env["PATH"] + const parts = fullPath.split(":") + const partsDedup = new Set(parts) + options.env["PATH"] = [...partsDedup].join(":") + } + const raw = _spawn(cmd, args, options) const cooked = new EventEmitter()