Skip to content

fix(setup): re-exec into fresh process when launching chat after setup#5848

Closed
bendusy wants to merge 1 commit into
NousResearch:mainfrom
bendusy:fix/offer-launch-chat-stdin-crash
Closed

fix(setup): re-exec into fresh process when launching chat after setup#5848
bendusy wants to merge 1 commit into
NousResearch:mainfrom
bendusy:fix/offer-launch-chat-stdin-crash

Conversation

@bendusy
Copy link
Copy Markdown

@bendusy bendusy commented Apr 7, 2026

Summary

  • _offer_launch_chat() calls cmd_chat() in-process after the setup wizard's interactive input() prompts, but stdin (fd 0) is left in a state that prompt_toolkit's asyncio selector cannot register, causing OSError: [Errno 22] Invalid argument
  • Replace the in-process call with os.execvp(), matching the existing pattern in main.py (cmd_sessions browse at L5175-5183)
  • Prefer the installed hermes binary via shutil.which(), fall back to python -m hermes_cli.main

Traceback

File ".../vt100.py", line 165, in _attached_input
    loop.add_reader(fd, callback_wrapper)
  File ".../selector_events.py", line 271, in _add_reader
    self._selector.register(fd, selectors.EVENT_READ, ...)
  File ".../selectors.py", line 523, in register
    self._selector.control([kev], 0, 0)
OSError: [Errno 22] Invalid argument

Test plan

  • Run hermes setup on a fresh config (first-time quick setup path)
  • Answer "Y" to "Launch hermes chat now?" — chat should open without crash
  • Verify the same works when hermes is not on PATH (fallback to python -m hermes_cli.main)

After the setup wizard's interactive prompts, stdin (fd 0) is left in a
state that prompt_toolkit's asyncio selector cannot register, causing:

  OSError: [Errno 22] Invalid argument

Replace the in-process cmd_chat() call with os.execvp(), matching the
existing pattern in main.py (cmd_sessions browse). This gives
prompt_toolkit a clean process with fresh stdin and event loop state.
@teknium1
Copy link
Copy Markdown
Contributor

Thanks for the fix @bendusy! The approach here is exactly right.

This is an automated hermes-sweeper review. After investigation, this PR can be closed — the identical fix landed on main via commit 704488b20 ('fix(setup): relaunch chat in a fresh process'), which replaced the in-process cmd_chat() call with os.execvp() and added _resolve_hermes_chat_argv() with the same shutil.which("hermes") + python -m hermes_cli.main fallback logic.

Evidence:

  • hermes_cli/setup.py lines 3119–3144 contain both _resolve_hermes_chat_argv() and the os.execvp-based _offer_launch_chat() matching this PR's approach exactly.
  • The fix shipped well before current HEAD — your diagnosis was correct and the solution was sound.

@teknium1 teknium1 closed this Apr 27, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 30, 2026
@alt-glitch
Copy link
Copy Markdown
Collaborator

Likely duplicate of #6415 — same root cause: stdin left dirty after setup wizard, prompt_toolkit selector fails. Same fix approach (os.execvp for clean process). See also #8843.

@alt-glitch
Copy link
Copy Markdown
Collaborator

Likely duplicate of #6415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants