Skip to content

Commit 9576b15

Browse files
committed
fix(bash): compose plugin PATH instead of stomping system PATH
When plugins return PATH entries via the shell.env hook, prepend them to the existing system PATH instead of replacing it entirely. This preserves standard paths like /usr/bin.
1 parent 5d3dba6 commit 9576b15

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/opencode/src/tool/bash.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,15 @@ async function ask(ctx: Tool.Context, scan: Scan) {
305305

306306
async function shellEnv(ctx: Tool.Context, cwd: string) {
307307
const extra = await Plugin.trigger("shell.env", { cwd, sessionID: ctx.sessionID, callID: ctx.callID }, { env: {} })
308+
// Extract plugin PATH before spreading to compose rather than stomp
309+
const env: Record<string, string> = { ...extra.env }
310+
const paths = env.PATH ?? ""
311+
delete env.PATH
308312
return {
309313
...process.env,
310-
...extra.env,
314+
...env,
315+
// Compose PATH: plugin bins prepended, system PATH preserved
316+
...(paths && { PATH: `${paths}${path.delimiter}${process.env.PATH ?? ""}` }),
311317
}
312318
}
313319

0 commit comments

Comments
 (0)