fix: relaunch chat with a fresh tty after setup#8843
Closed
XiaoDcs wants to merge 1 commit into
Closed
Conversation
Collaborator
This was referenced Apr 30, 2026
Contributor
|
Closing — superseded by #26077 (merged as commit d3d5916), which preventively probes kqueue at startup and falls back to SelectSelector when fd 0 cannot be registered. The widened except-clause matching EINVAL / EBADF / 'Invalid argument' — which most PRs in this cluster including yours added — is also included. Thanks for the fix; closing as duplicate of the merged work. |
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
hermes chatafter setup using a fresh/dev/tty-backed subprocess instead ofos.execvpcurl ... | bashInvalid argumentlike other broken-stdin prompt_toolkit startup failuresProblem
When Hermes is installed via the curl installer on macOS, the setup wizard can successfully run interactively by reading from
/dev/tty, but choosingLaunch hermes chat now?may immediately crash with:KeyError: '0 is not registered'OSError: [Errno 22] Invalid argumentThis happens because the setup process re-execs into
hermes chat, and the new prompt_toolkit app inherits a broken stdin/fd 0 state from the installer/setup chain.Fix
Instead of replacing the current process with
os.execvp, launch chat in a new subprocess wired directly to a freshly opened/dev/tty. This gives prompt_toolkit a clean TTY-backed stdin/stdout/stderr and avoids the broken inherited fd state.As a small follow-up hardening step, the CLI stdin fallback now also treats
Invalid argumentas a broken-stdin startup error and prints the same friendly guidance instead of a raw traceback.Testing
venv/bin/python -m pytest tests/hermes_cli/test_setup.py -qprintf "/exit\n" | hermes chatexits cleanly after the setup-launch change