Skip to content

fix(windows): guard fcntl/termios import + add __main__.py launcher - #21465

Closed
Alterpolo wants to merge 3 commits into
NousResearch:mainfrom
Alterpolo:fix/windows-compat-launcher
Closed

fix(windows): guard fcntl/termios import + add __main__.py launcher#21465
Alterpolo wants to merge 3 commits into
NousResearch:mainfrom
Alterpolo:fix/windows-compat-launcher

Conversation

@Alterpolo

Copy link
Copy Markdown

Summary

Two small fixes for native Windows Python compatibility:

  • hermes_cli/__main__.py — adds the standard package entry-point so Hermes can be invoked as python -m hermes_cli from a cloned repo or CI environment where the hermes binary is not on PATH. Delegates unconditionally to hermes_cli.main:main(); behaviour is byte-identical to the installed command for all subcommands and exit codes.

  • hermes_cli/pty_bridge.py — guards fcntl/termios imports behind a try/except ImportError. Both modules are POSIX-only and absent from native Windows Python. The module already gates PTY operations on _PTY_AVAILABLE and raises PtyUnavailableError at instantiation; only the import needs to succeed. Without this guard, any command that triggers web_server.py (which imports pty_bridge unconditionally) crashes at module-load time on Windows — even commands unrelated to the PTY bridge.

  • scripts/release.py — contributor email mapping for this PR's author.

Test plan

  • python -m hermes_cli --version on a repo checkout (no installed binary) → version string on stdout, exit 0
  • python -m hermes_cli doctor → same output as hermes doctor
  • On Windows native Python: python -c "import hermes_cli.pty_bridge" → no ImportError
  • ruff check hermes_cli/__main__.py hermes_cli/pty_bridge.py → no errors

🤖 Generated with Claude Code

Alterpolo and others added 3 commits May 7, 2026 21:13
Adds the standard Python package entry-point so that Hermes can be
invoked as `python -m hermes_cli` from a cloned repo or CI environment
where the `hermes` binary is not on PATH.

The file delegates unconditionally to `hermes_cli.main:main()` with no
argument or environment mutation, keeping behaviour byte-identical to the
installed command for all subcommands and exit codes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fcntl and termios are POSIX-only and absent from native Windows Python.
The module already gates PTY operations on _PTY_AVAILABLE and raises
PtyUnavailableError at instantiation, so only the import needs to
succeed.

Without this guard, any command that triggers web_server.py (which
imports pty_bridge unconditionally) crashes at module-load time on
Windows — even commands that have nothing to do with the PTY bridge.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have labels May 7, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This appears to be a resubmission of #21453 (same title, same changes). Related to tracking issue #5246.

tcflying added a commit to tcflying/hermes-agent-windows-rust-old that referenced this pull request May 15, 2026
- psutil-based process start time fallback (NousResearch#25502)
- ConPTY Bridge for native Windows terminal support
- prompt_toolkit Vt100 output fallback for Git Bash
- Git Bash path resolution (/d/path -> D:\path)
- UTF-8 encoding for subprocess calls (doctor, schtasks)
- Bash forward slashes in cron scripts (NousResearch#23404)
- schtasks mbcs encoding for non-ASCII task names (NousResearch#24417, NousResearch#24478)
- __main__.py launcher for python -m hermes_cli (NousResearch#21465)
- shutdown_forensics Windows process snapshot
- Comprehensive E2E test suite with 23 tests

Fixes Windows native installation without WSL2 requirement.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@teknium1

teknium1 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded by #42251, which adds a real ConPTY backend instead of import-guarding the POSIX bridge. Your PR was the right shape for keeping the non-chat dashboard tabs alive on Windows when only pty_bridge is available, but the actual fix is making /chat itself work — live-tested in #42251 against a real hermes --tui (node entry.js) child rendered through ConPTY. Thanks for surfacing the failure mode.

@Alterpolo Alterpolo closed this Jun 10, 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 P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants