Fix /dev/tty open on Windows in _start_stdout_capture! #40

Closed
mind6 wants to merge 1 commit from fix/windows-dev-tty into main
mind6 commented 2026-05-09 13:39:47 -07:00 (Migrated from github.com)

Summary

On Windows, running kaimon crashes at startup with:

ERROR: SystemError: opening file "/dev/tty": No such file or directory
 [6] _start_stdout_capture!()
   @ Kaimon .../src/tui/io.jl:211

/dev/tty is Unix-only. On Windows the equivalent controlling-terminal device is CON. This PR uses Sys.iswindows() to pick the right path.

Why this matters

_TUI_REAL_STDOUT holds a handle to the real terminal that survives redirect_stdout(), and that handle is later assigned to Tachikoma.Terminal.io (src/tui/lifecycle.jl:213) so the TUI can render even while stdout is being captured into the Server log buffer. Without a working terminal handle on Windows, the TUI can't start at all.

Test plan

  • Verified open("CON", "w") returns a writable console handle on Windows 11 / Julia 1.12.5.
  • After patch, kaimon proceeds past _start_stdout_capture! and into TUI init (a separate, unrelated ZMQ: Protocol not supported error from ipc:// sockets in gate_client.jl is the next Windows blocker — out of scope for this PR; happy to file an issue).
  • Patch is a no-op on Unix (still uses /dev/tty).

Note on broader Windows support

This is a one-line compatibility fix and does not claim to make Kaimon fully Windows-ready. The ZMQ IPC transport (ipc://) is also unavailable on Windows in the standard ZMQ_jll build, which would need a separate fix (e.g. switching to tcp://127.0.0.1:<port> or a Windows-named-pipe transport). Filing that as a separate issue.

## Summary On Windows, running `kaimon` crashes at startup with: ``` ERROR: SystemError: opening file "/dev/tty": No such file or directory [6] _start_stdout_capture!() @ Kaimon .../src/tui/io.jl:211 ``` `/dev/tty` is Unix-only. On Windows the equivalent controlling-terminal device is `CON`. This PR uses `Sys.iswindows()` to pick the right path. ## Why this matters `_TUI_REAL_STDOUT` holds a handle to the real terminal that survives `redirect_stdout()`, and that handle is later assigned to `Tachikoma.Terminal.io` (`src/tui/lifecycle.jl:213`) so the TUI can render even while `stdout` is being captured into the Server log buffer. Without a working terminal handle on Windows, the TUI can't start at all. ## Test plan - [x] Verified `open("CON", "w")` returns a writable console handle on Windows 11 / Julia 1.12.5. - [x] After patch, `kaimon` proceeds past `_start_stdout_capture!` and into TUI init (a separate, unrelated `ZMQ: Protocol not supported` error from `ipc://` sockets in `gate_client.jl` is the next Windows blocker — out of scope for this PR; happy to file an issue). - [x] Patch is a no-op on Unix (still uses `/dev/tty`). ## Note on broader Windows support This is a one-line compatibility fix and does not claim to make Kaimon fully Windows-ready. The ZMQ IPC transport (`ipc://`) is also unavailable on Windows in the standard `ZMQ_jll` build, which would need a separate fix (e.g. switching to `tcp://127.0.0.1:<port>` or a Windows-named-pipe transport). Filing that as a separate issue.
kahliburke commented 2026-06-19 15:00:18 -07:00 (Migrated from github.com)

Thanks @mind6 — this fix has landed on 2.0-integration: _start_stdout_capture! now opens CON on Windows instead of /dev/tty (see src/tui/io.jl, credited to this PR). Closing as incorporated. Remaining Windows work (the ZMQ ipc://→TCP switch) is tracked/done in #41.

Thanks @mind6 — this fix has landed on `2.0-integration`: `_start_stdout_capture!` now opens `CON` on Windows instead of `/dev/tty` (see `src/tui/io.jl`, credited to this PR). Closing as incorporated. Remaining Windows work (the ZMQ `ipc://`→TCP switch) is tracked/done in #41.

Pull request closed

Sign in to join this conversation.
No description provided.