Skip to content

feat(doctor): detect fake Windows python.exe stubs and PE subsystem#48581

Open
jinwd-maker wants to merge 2 commits into
NousResearch:mainfrom
jinwd-maker:feat/doctor-windows-python-stubs
Open

feat(doctor): detect fake Windows python.exe stubs and PE subsystem#48581
jinwd-maker wants to merge 2 commits into
NousResearch:mainfrom
jinwd-maker:feat/doctor-windows-python-stubs

Conversation

@jinwd-maker

Copy link
Copy Markdown

Summary

Adds a Windows Python Environment section to hermes doctor that detects a common Windows footgun:

Windows ships 0-byte python.exe / python3.exe stubs in %LOCALAPPDATA%\Microsoft\WindowsApps. These App Execution Aliases appear first on PATH and mask the real Python installation, silently breaking any subprocess that resolves python via PATH.

What it checks

Check Detection Severity
0-byte stubs in WindowsApps File size = 0 ⚠ warn
python PATH resolution Resolves to WindowsApps stub ✗ fail
venv pythonw.exe subsystem PE header subsystem field ✓ ok / ⚠ warn
pythonw PATH resolution Resolves to GUI binary ✓ ok / ✗ fail

PE subsystem parser

Includes a zero-dependency _pe_subsystem() helper that reads the Windows PE Optional Header to determine whether a .exe has:

  • 2 = IMAGE_SUBSYSTEM_WINDOWS_GUI (correct for pythonw.exe)
  • 3 = IMAGE_SUBSYSTEM_WINDOWS_CUI (correct for python.exe)
  • None = not a valid PE file (0-byte stub)

Example output (affected system)

Fix instructions

  • Disable Python App Execution Aliases in Windows Settings → Apps → App execution aliases
  • Or re-order PATH so venv/Scripts precedes WindowsApps

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels Jun 18, 2026
Adds a 'Windows Python Environment' section to hermes doctor that
detects the Windows App Execution Alias trap on Windows 10/11.

Windows ships 0-byte python.exe / python3.exe stubs in
%LOCALAPPDATA%\Microsoft\WindowsApps. These App Execution Aliases
appear first on PATH and mask the real Python installation. Hermes
watchdog and cron scripts that resolve 'python' via PATH accidentally
pick up the fake stub, which can't run any scripts.

Checks performed:
- 0-byte stub detection in WindowsApps
- PATH resolution check: does 'python' resolve to the fake?
- PE subsystem verification: is venv pythonw.exe actually GUI
  (IMAGE_SUBSYSTEM_WINDOWS_GUI=2) and not CUI?
- pythonw resolution: does PATH pick the right one?

Includes _pe_subsystem() helper that reads the PE Optional Header
subsystem field without external dependencies.
@jinwd-maker jinwd-maker force-pushed the feat/doctor-windows-python-stubs branch from 0a7204a to 6dde95b Compare June 18, 2026 18:42
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/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants