fix(gcp): add /usr/local/bin to .spawnrc PATH for npm-global agents (#2681)

GCP VMs install kilocode (and other npm-global agents) to /usr/local/bin
via `npm install -g`. The .spawnrc PATH export relied on $PATH inheriting
/usr/local/bin from the SSH/login shell chain, but on GCP VMs the PATH
can be minimal depending on how the session is initiated (login shell
sourcing order, /etc/profile.d availability). Explicitly include
/usr/local/bin to ensure npm globally-installed binaries are always
findable regardless of base PATH.

Also updates fix.ts to keep its PATH in sync with generateEnvConfig().

Fixes #2679

Agent: code-health

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
A 2026-03-16 00:00:09 -07:00 committed by GitHub
parent 09576f16ef
commit e5725b9a66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@openrouter/spawn",
"version": "0.20.1",
"version": "0.20.2",
"type": "module",
"bin": {
"spawn": "cli.js"

View file

@ -51,7 +51,7 @@ export function buildFixScript(manifest: Manifest, agentKey: string): string {
// Always prepend IS_SANDBOX and PATH — matches generateEnvConfig() in shared/agents.ts
lines.push(" printf 'export IS_SANDBOX=\\x271\\x27\\n'");
lines.push(
" printf 'export PATH=\"$HOME/.npm-global/bin:$HOME/.bun/bin:$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.claude/local/bin:$PATH\"\\n'",
" printf 'export PATH=\"$HOME/.npm-global/bin:$HOME/.bun/bin:$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.claude/local/bin:/usr/local/bin:$PATH\"\\n'",
);
for (const [key, template] of envEntries) {
const value = resolveEnvTemplate(template);

View file

@ -168,7 +168,7 @@ export function generateEnvConfig(pairs: string[]): string {
"# [spawn:env]",
"export IS_SANDBOX='1'",
"# Ensure agent binaries are in PATH on reconnect",
'export PATH="$HOME/.npm-global/bin:$HOME/.bun/bin:$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.claude/local/bin:$PATH"',
'export PATH="$HOME/.npm-global/bin:$HOME/.bun/bin:$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.claude/local/bin:/usr/local/bin:$PATH"',
];
for (const pair of pairs) {
const eqIdx = pair.indexOf("=");