Skip to content

CLI Fix: Catch EINVAL from stdin selector registration - #11253

Closed
siddhantsomani wants to merge 1 commit into
NousResearch:mainfrom
siddhantsomani:fix/stdin-einval-handler
Closed

CLI Fix: Catch EINVAL from stdin selector registration#11253
siddhantsomani wants to merge 1 commit into
NousResearch:mainfrom
siddhantsomani:fix/stdin-einval-handler

Conversation

@siddhantsomani

@siddhantsomani siddhantsomani commented Apr 16, 2026

Copy link
Copy Markdown

Context

I just installed Hermes agent on my laptop. The installation went through but errored when I launched it. I know how to fix it in my local but it would be good to not crash in such cases.

Error

On macOS with uv-managed Python, launching hermes chat crashes with an unhandled traceback on exit:

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

Fix

The existing except (KeyError, OSError) handler in HermesCLI.run() already tries to catch this class of error (#6393), but the string check only matches "is not registered" and "Bad file descriptor". The macOS kqueue path raises EINVAL ("Invalid argument"), so the error fell through to raise instead of showing the friendly "reinstall Python via pyenv/Homebrew" message.

Added "Invalid argument" to the condition.

@siddhantsomani siddhantsomani changed the title fix(cli): catch EINVAL from stdin selector registration CLI Fix: Catch EINVAL from stdin selector registration Apr 16, 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 25, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #13251 — both add EINVAL handling to the stdin selector guard for #6393. Multiple competing PRs exist (#11866, #8796).

@teknium1

Copy link
Copy Markdown
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.

@teknium1 teknium1 closed this May 15, 2026
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