Skip to content

Commit 8900759

Browse files
committed
fix: export the pnpm path inside the command, not the environment
bash -l sources the system profile, which rebuilds PATH from scratch and threw away the prepend, so the bootstrap still reached corepack's shim. Exporting inside the command runs after the profile.
1 parent c876a6e commit 8900759

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎backend/src/chat/local-sandbox.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,16 @@ const createSession = async (root: string, base: string, ports: number[]) => {
7676
// AGENT_PNPM_BIN points at a directory holding a real one, which goes
7777
// first so the shim is never reached. Unset on a developer machine, where
7878
// pnpm is already a real install.
79+
// Exported inside the command, not through env: `bash -l` sources the
80+
// system profile, which rebuilds PATH and discards anything set here.
7981
const pnpmBin = process.env.AGENT_PNPM_BIN;
80-
const PATH = pnpmBin
81-
? `${pnpmBin}:${inherited.PATH ?? ''}`
82-
: inherited.PATH;
82+
const script = pnpmBin
83+
? `export PATH=${JSON.stringify(pnpmBin)}:"$PATH"; ${command}`
84+
: command;
8385

84-
return nodeSpawn('bash', ['-lc', command], {
86+
return nodeSpawn('bash', ['-lc', script], {
8587
cwd: workingDirectory ? resolvePath(workingDirectory) : base,
86-
env: { ...inherited, ...(PATH ? { PATH } : {}), ...env },
88+
env: { ...inherited, ...env },
8789
signal: abortSignal,
8890
});
8991
};

0 commit comments

Comments
 (0)