Skip to content

The open-source app everyone uses to manage agents at work

Stop leaking host process.env into the remote Pi SSH probe (#5275)

Devin Foley44c365dea33f
diff --git a/packages/adapters/pi-local/src/server/test.ts b/packages/adapters/pi-local/src/server/test.ts
index 25ef6d3e2e..3ea8dff2a5 100644
--- a/packages/adapters/pi-local/src/server/test.ts
+++ b/packages/adapters/pi-local/src/server/test.ts
@@ -248,6 +248,17 @@ export async function testEnvironment(
args.push("--tools", "read");
if (extraArgs.length > 0) args.push(...extraArgs);
+ // For remote targets, do NOT spread the host process.env into the probe
+ // env: it leaks macOS-only PATH, HOME, TMPDIR, etc. into the remote shell.
+ // In particular the Mac PATH overrides the nvm-sourced PATH that
+ // buildSshSpawnTarget sets up, which on Linux SSH targets resolves `node`
+ // to /usr/bin/node (Node 18) instead of nvm's Node 22, causing pi-tui to
+ // crash with `Invalid regular expression flags` on its /v unicode regex.
+ // Match the pattern used by claude_local / codex_local / gemini_local /
+ // opencode_local probes: send only the user-configured adapter env across
+ // SSH. Local probes still get the full runtimeEnv.
+ const probeEnv = targetIsRemote ? normalizeEnv(env) : runtimeEnv;
+
try {
const probe = await runAdapterExecutionTargetProcess(
runId,
@@ -256,7 +267,7 @@ export async function testEnvironment(
args,
{
cwd,
- env: runtimeEnv,
+ env: probeEnv,
timeoutSec: 60,
graceSec: 5,
onLog: async () => {},