Bug Description
Summary
Running hermes setup on Windows fails with two related errors:
UnicodeDecodeError in the subprocess reader thread due to non-UTF-8 encoded wmic output
AttributeError when trying to access result.stdout (which becomes None after the decode error)
Error Messages
Primary Error:
- UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 8177: invalid continuation byte File "C:\Python311\Lib\subprocess.py", line 1597, in _readerthread self._out.write(b''.join(res)) File "", line 322, in decode
Secondary Error (consequence of the first):
- AttributeError: 'NoneType' object has no attribute 'split' File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\gateway.py", line 290, in _scan_gateway_pids for line in result.stdout.split("\n"):
Stack Trace
Exception in thread Thread-1 (_readerthread): Traceback (most recent call last): File "C:\Python311\Lib\threading.py", line 1038, in _bootstrap_inner self.run() File "C:\Python311\Lib\threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "C:\Python311\Lib\subprocess.py", line 1597, in _readerthread self._out.write(b''.join(res)) File "", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 8177: invalid continuation byte
Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\main.py", line 10160, in main args.func(args) File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\main.py", line 1522, in cmd_setup run_setup_wizard(args) File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\setup.py", line 3080, in run_setup_wizard _run_first_time_quick_setup(config, hermes_home, is_existing) File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\setup.py", line 3182, in _run_first_time_quick_setup setup_gateway(config) File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\setup.py", line 2405, in setup_gateway service_running = _is_service_running() File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\gateway.py", line 3186, in _is_service_running return len(find_gateway_pids()) > 0 File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\gateway.py", line 370, in find_gateway_pids for pid in _scan_gateway_pids(_exclude, all_profiles=all_profiles): File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\gateway.py", line 290, in _scan_gateway_pids for line in result.stdout.split("\n"): AttributeError: 'NoneType' object has no attribute 'split'
Steps to Reproduce
- Run
hermes setup on a Windows system (particularly with non-English system locale)
- During the gateway service detection phase, the error occurs
Expected Behavior
The function should:
- Decode wmic output using the system's code page (or handle encoding errors gracefully)
- Successfully extract process IDs and command lines
- Allow the setup wizard to continue
Actual Behavior
The function crashes with UnicodeDecodeError in the subprocess reader thread, then AttributeError when trying to access result.stdout.
Affected Component
Setup / Installation
Messaging Platform (if gateway-related)
No response
Debug Report
Report https://paste.rs/3LZ59
agent.log https://paste.rs/uAhOd
gateway.log https://paste.rs/RmnLg
Operating System
WIndows 10
Python Version
3.11.5
Hermes Version
0.11.0 (2026.4.23)
Additional Logs / Traceback (optional)
Root Cause Analysis (optional)
Root Cause
The _scan_gateway_pids() function in hermes_cli/gateway.py (lines 278-290) executes the Windows wmic command with text=True and encoding='utf-8' (implicit), but:
-
wmic output is not UTF-8: On Windows systems, especially with non-English locales, wmic outputs text in the system's code page (e.g., cp936 for Chinese, cp1252 for Western European), NOT UTF-8.
-
UnicodeDecodeError in subprocess: When Python tries to decode wmic's output as UTF-8, it fails if the output contains non-UTF-8 bytes (like 0xd0 at position 8177), causing the reader thread to crash.
-
Cascading failure: After the decode error, result.stdout becomes None, leading to the AttributeError.
Current problematic code (lines 278-290):
if is_windows():
result = subprocess.run(
["wmic", "process", "get", "ProcessId,CommandLine", "/FORMAT:LIST"],
capture_output=True,
text=True, # ← Implicitly uses UTF-8 encoding
timeout=10,
)
if result.returncode != 0:
return []
current_cmd = ""
for line in result.stdout.split("\n"): # ← stdout is None after decode error
Proposed Fix (optional)
Use system encoding
if is_windows():
result = subprocess.run(
["wmic", "process", "get", "ProcessId,CommandLine", "/FORMAT:LIST"],
capture_output=True,
text=True,
encoding='utf-8', # Explicitly specify
errors='ignore', # ← Ignore undecodable bytes instead of crashing
timeout=10,
)
if result.returncode != 0 or result.stdout is None:
return []
current_cmd = ""
for line in result.stdout.split("\n"):
Are you willing to submit a PR for this?
Bug Description
Summary
Running
hermes setupon Windows fails with two related errors:UnicodeDecodeErrorin the subprocess reader thread due to non-UTF-8 encoded wmic outputAttributeErrorwhen trying to accessresult.stdout(which becomes None after the decode error)Error Messages
Primary Error:
Secondary Error (consequence of the first):
Stack Trace
Exception in thread Thread-1 (_readerthread): Traceback (most recent call last): File "C:\Python311\Lib\threading.py", line 1038, in _bootstrap_inner self.run() File "C:\Python311\Lib\threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "C:\Python311\Lib\subprocess.py", line 1597, in _readerthread self._out.write(b''.join(res)) File "", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 8177: invalid continuation byte
Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\main.py", line 10160, in main args.func(args) File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\main.py", line 1522, in cmd_setup run_setup_wizard(args) File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\setup.py", line 3080, in run_setup_wizard _run_first_time_quick_setup(config, hermes_home, is_existing) File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\setup.py", line 3182, in _run_first_time_quick_setup setup_gateway(config) File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\setup.py", line 2405, in setup_gateway service_running = _is_service_running() File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\gateway.py", line 3186, in _is_service_running return len(find_gateway_pids()) > 0 File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\gateway.py", line 370, in find_gateway_pids for pid in _scan_gateway_pids(_exclude, all_profiles=all_profiles): File "C:\Users\feng7\AppData\Local\hermes\hermes-agent\hermes_cli\gateway.py", line 290, in _scan_gateway_pids for line in result.stdout.split("\n"): AttributeError: 'NoneType' object has no attribute 'split'
Steps to Reproduce
hermes setupon a Windows system (particularly with non-English system locale)Expected Behavior
The function should:
Actual Behavior
The function crashes with UnicodeDecodeError in the subprocess reader thread, then AttributeError when trying to access result.stdout.
Affected Component
Setup / Installation
Messaging Platform (if gateway-related)
No response
Debug Report
Operating System
WIndows 10
Python Version
3.11.5
Hermes Version
0.11.0 (2026.4.23)
Additional Logs / Traceback (optional)
Root Cause Analysis (optional)
Root Cause
The
_scan_gateway_pids()function inhermes_cli/gateway.py(lines 278-290) executes the Windowswmiccommand withtext=Trueandencoding='utf-8'(implicit), but:wmic output is not UTF-8: On Windows systems, especially with non-English locales,
wmicoutputs text in the system's code page (e.g.,cp936for Chinese,cp1252for Western European), NOT UTF-8.UnicodeDecodeError in subprocess: When Python tries to decode wmic's output as UTF-8, it fails if the output contains non-UTF-8 bytes (like
0xd0at position 8177), causing the reader thread to crash.Cascading failure: After the decode error,
result.stdoutbecomesNone, leading to theAttributeError.Current problematic code (lines 278-290):
Proposed Fix (optional)
Use system encoding
Are you willing to submit a PR for this?