fix(claude-bridge): recover login-shell PATH for bare CLI launches#477
Merged
Merged
Conversation
- what: merge login-shell PATH into claude-bridge spawn env when the backend launches a bare command without an explicit PATH override - why: isolated runtime and launchd-style environments can drop user PATH entries, so bare `claude` fails with ENOENT even though it works in the operator login shell - risk: bridge launches now consult login-shell PATH on non-Windows hosts; test coverage keeps the merge scoped to bare-command launches only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review Fast Path
claudeagain even when the inherited PATH is only system bins.pnpm exec vitest run src/agents/claude-bridge.test.tspassed; direct stripped-env repro still shows bareclaudefails withENOENT, and the new bridge test proves the spawn env now merges login-shell PATH before launch.claude-bridgeno longer assumes the service/runtime PATH already includes user-installed CLI bins like/Users/user/.local/bin.claude-bridge/sonnetis fixed end-to-end yet; it only fixes the bridge executable lookup boundary.Why This Matters
claudecan disappear even though it works in the operator login shell.Scope Boundary
src/agents/claude-bridge.ts,src/agents/claude-bridge.test.tsVerification
pnpm exec vitest run src/agents/claude-bridge.test.tsenv -i HOME="$HOME" USER="$USER" LOGNAME="$LOGNAME" TMPDIR="${TMPDIR:-/tmp}" PATH="/usr/bin:/bin:/usr/sbin:/sbin" /opt/homebrew/bin/node -e 'const { spawnSync } = require("node:child_process"); const before = spawnSync("claude", ["--version"], { encoding: "utf8" }); console.log(JSON.stringify({ beforeError: before.error ? { code: before.error.code, message: before.error.message } : null, beforeStatus: before.status ?? null }));'{"beforeError":{"code":"ENOENT","message":"spawnSync claude ENOENT"},"beforeStatus":null}/Users/user/.local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbinwhen login-shell PATH is available and runtime PATH is strippedAI Assistance