Skip to content

fix: detect $bunfs virtual paths for daemon autostart in Bun binaries#86

Merged
benvinegar merged 2 commits intomainfrom
fix/daemon-autostart-bunfs-detection
Mar 23, 2026
Merged

fix: detect $bunfs virtual paths for daemon autostart in Bun binaries#86
benvinegar merged 2 commits intomainfrom
fix/daemon-autostart-bunfs-detection

Conversation

@benvinegar
Copy link
Copy Markdown
Member

Summary

  • Fixes daemon autostart that was broken in v0.6.0-beta.1 despite PR fix: daemon autostart for prebuilt npm binaries #84
  • PR fix: daemon autostart for prebuilt npm binaries #84 had the argv[0]/execPath relationship backwards. In Bun-compiled binaries, argv is ["bun", "/$bunfs/root/<name>", ...userArgs] and execPath is the real binary on disk — not the other way around
  • The old code matched the /$bunfs/ virtual path against SCRIPT_ENTRYPOINT_PATTERN (because it contains /), spawning bun /$bunfs/root/hunk mcp serve — a path that doesn't exist outside the binary
  • Fix: detect the /$bunfs/ prefix in argv[1] and use execPath directly

How it was verified

  • Built a standalone Bun binary to confirm actual argv/execPath values
  • Confirmed the installed hunkdiff-darwin-arm64 binary at v0.6.0-beta.1 contains the old (broken) code
  • Typecheck, daemon-launcher tests (4/4), and TTY smoke tests all pass

Test plan

  • Typecheck passes
  • All daemon-launcher tests pass with corrected test case modeling real Bun argv
  • TTY smoke test passes
  • Manual: rebuild, install, kill any daemon, run hunk show — daemon should auto-start

🤖 Generated with Claude Code

benvinegar and others added 2 commits March 23, 2026 14:10
The previous fix (PR #84) assumed argv[0] was the real binary and
execPath was the embedded Bun runtime, but it's the opposite: Bun
compiled binaries report argv as ["bun", "/$bunfs/root/<name>", ...]
with execPath pointing to the real binary on disk. The old code matched
the $bunfs virtual path against SCRIPT_ENTRYPOINT_PATTERN (because it
contains "/"), spawning `bun /$bunfs/root/hunk mcp serve` — a path
that doesn't exist outside the binary.

Fix: detect the /$bunfs/ prefix in argv[1] and use execPath directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@benvinegar benvinegar merged commit 0047371 into main Mar 23, 2026
3 checks passed
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.

1 participant