Skip to content

Windows: hunk diff auto-launches daemon with invalid Bun argv #502

Description

@qqhhhh

Summary

On Windows x64 with hunkdiff@0.16.0, hunk.cmd diff opens the TUI correctly, but the live session daemon is not reachable. As a result, hunk.cmd session list --json hangs / never returns a session unless I manually start hunk.cmd daemon serve first.

The root cause appears to be that the auto-launched daemon command receives an extra B:/~BUN/root/hunk.exe argument.

Environment

  • OS: Windows x64
  • Shells tested:
    • Windows PowerShell 5.1
    • PowerShell 7.6.3
  • Node: v24.16.0
  • npm: 11.13.0
  • hunkdiff: 0.16.0
  • Install method:
npm.cmd install -g hunkdiff

Steps to reproduce

From a Git repository:

hunk.cmd diff

The TUI opens successfully.

In another terminal:

hunk.cmd session list --json

Expected: returns the live Hunk session.

Actual: it does not return a usable session. On my machine it hangs until manually killed.

Manual daemon workaround

If I manually start the daemon first:

hunk.cmd daemon serve

It prints:

Session broker API listening on http://127.0.0.1:47657/session-api
Session broker websocket listening on ws://127.0.0.1:47657/session

Then hunk.cmd diff registers successfully, and:

hunk.cmd session list --json

returns the live session.

Evidence

After launching only:

hunk.cmd diff

Hunk writes daemon metadata to:

%TEMP%\hunk-mcp\daemon-127-0-0-1-47657.json

The metadata contains:

{
  "command": "C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\hunkdiff\\node_modules\\hunkdiff-windows-x64\\bin\\hunk.exe",
  "args": [
    "B:/~BUN/root/hunk.exe",
    "daemon",
    "serve"
  ]
}

Running that command manually fails:

& "C:\Users\Administrator\AppData\Roaming\npm\node_modules\hunkdiff\node_modules\hunkdiff-windows-x64\bin\hunk.exe" "B:/~BUN/root/hunk.exe" daemon serve --help

Output:

hunk: Unknown command: B:/~BUN/root/hunk.exe

But running without the extra B:/~BUN/root/hunk.exe argument works:

& "C:\Users\Administrator\AppData\Roaming\npm\node_modules\hunkdiff\node_modules\hunkdiff-windows-x64\bin\hunk.exe" daemon serve --help

Output:

Usage: hunk daemon serve

Run the local Hunk session daemon and websocket session broker.

Notes

I found a related closed issue, #406, about hunk session * hanging indefinitely when the daemon is not running on Windows. This report is more specific: the TUI appears to try to auto-launch the daemon, but the generated daemon launch metadata includes an extra Bun virtual root argument.

Suspected cause

The Windows prebuilt binary / Bun-packaged executable seems to compute the daemon launch command incorrectly. It appears to treat B:/~BUN/root/hunk.exe as an entrypoint argument and passes it through to hunk.exe.

Possibly related code area: session broker daemon launcher / argv handling for packaged Bun executables on Windows.

Expected behavior

When hunk.cmd diff starts the TUI, it should auto-launch/connect to the session broker daemon with an equivalent of:

hunk.exe daemon serve

not:

hunk.exe B:/~BUN/root/hunk.exe daemon serve

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions