fix(desktop): evaluate daemon spawn env lazily to pick up PATH fix#1088
Merged
fix(desktop): evaluate daemon spawn env lazily to pick up PATH fix#1088
Conversation
DESKTOP_SPAWN_ENV was a top-level const in daemon-manager.ts that snapshotted process.env at module load. Because ESM imports are hoisted and evaluated before main/index.ts runs fix-path, the snapshot captured launchd's minimal PATH — missing ~/.local/bin, Homebrew, etc. The main process then had the corrected PATH, but every spawned daemon inherited the stale one and failed with "no agent CLI found" on fresh GUI launches. Convert it to desktopSpawnEnv() so process.env is read at call time, after fix-path has already updated it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
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.
Summary
DESKTOP_SPAWN_ENVindaemon-manager.tswas a top-level const that snapshottedprocess.envat module load time. ESM imports are hoisted and evaluated beforemain/index.tsrunsfix-path, so the snapshot captured launchd's minimal PATH (missing~/.local/bin, Homebrew paths from.zshrc, etc.).execFile(bin, args, { env: DESKTOP_SPAWN_ENV })inherited the stale one and failed withno agent CLI foundon fresh GUI launches — even though the user's shell hadclaudeon PATH.DESKTOP_SPAWN_ENVinto adesktopSpawnEnv()function soprocess.envis read at call time, afterfix-path+ fallback-prepend have already updated it.Repro (before fix)
Launching a packaged Multica.app from Finder on a fresh account with
claudeinstalled at~/.local/bin/claude:~/.multica/profiles/<profile>/daemon.log:app.asarshowed thefix-pathblock is present and runs, butDESKTOP_SPAWN_ENVwas already frozen before it executed.Test plan
CSC_IDENTITY_AUTO_DISCOVERY=false pnpm --filter @multica/desktop package -- --mac dmg -p nevermultica daemonprocesses.appinto/Applications, launch from Finderagents=[claude]appears in~/.multica/profiles/<profile>/daemon.logpnpm typecheckpasses🤖 Generated with Claude Code