Skip to content

fix(desktop): evaluate daemon spawn env lazily to pick up PATH fix#1088

Merged
ldnvnbl merged 1 commit intomainfrom
fix/desktop-spawn-env-path-snapshot
Apr 15, 2026
Merged

fix(desktop): evaluate daemon spawn env lazily to pick up PATH fix#1088
ldnvnbl merged 1 commit intomainfrom
fix/desktop-spawn-env-path-snapshot

Conversation

@devv-eve
Copy link
Copy Markdown
Collaborator

Summary

  • DESKTOP_SPAWN_ENV in daemon-manager.ts was a top-level const that snapshotted process.env at module load time. ESM imports are hoisted and evaluated before main/index.ts runs fix-path, so the snapshot captured launchd's minimal PATH (missing ~/.local/bin, Homebrew paths from .zshrc, etc.).
  • The main process ended up with the corrected PATH, but every daemon child spawned via execFile(bin, args, { env: DESKTOP_SPAWN_ENV }) inherited the stale one and failed with no agent CLI found on fresh GUI launches — even though the user's shell had claude on PATH.
  • Convert DESKTOP_SPAWN_ENV into a desktopSpawnEnv() function so process.env is read at call time, after fix-path + fallback-prepend have already updated it.

Repro (before fix)

Launching a packaged Multica.app from Finder on a fresh account with claude installed at ~/.local/bin/claude:

  • ~/.multica/profiles/<profile>/daemon.log:
    Error: no agent CLI found: install claude, codex, opencode, openclaw, hermes, or gemini and ensure it is on PATH
    
  • Running the bundled CLI directly confirmed the daemon itself works when PATH is correct:
    TEST 1 (PATH without ~/.local/bin) → Error: no agent CLI found
    TEST 2 (PATH with ~/.local/bin)    → daemon started, agents=[claude] ✅
    
  • Inspecting the packaged app.asar showed the fix-path block is present and runs, but DESKTOP_SPAWN_ENV was already frozen before it executed.

Test plan

  • Package an unsigned build: CSC_IDENTITY_AUTO_DISCOVERY=false pnpm --filter @multica/desktop package -- --mac dmg -p never
  • Quit any running Multica.app and kill any stray multica daemon processes
  • Drag the new .app into /Applications, launch from Finder
  • Confirm the daemon starts and agents=[claude] appears in ~/.multica/profiles/<profile>/daemon.log
  • Sanity check: pnpm typecheck passes

🤖 Generated with Claude Code

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>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
multica-web Ignored Ignored Apr 15, 2026 10:47am
multica-web-production Ignored Ignored Apr 15, 2026 10:47am

Request Review

@ldnvnbl ldnvnbl merged commit 8a55473 into main Apr 15, 2026
5 checks passed
@ldnvnbl ldnvnbl deleted the fix/desktop-spawn-env-path-snapshot branch April 15, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants