fix(gateway-windows): handle non-ASCII paths and uv pythonw shim on CJK Windows - #40374
Closed
Shura0307 wants to merge 1 commit into
Closed
fix(gateway-windows): handle non-ASCII paths and uv pythonw shim on CJK Windows#40374Shura0307 wants to merge 1 commit into
Shura0307 wants to merge 1 commit into
Conversation
…hinese Windows Two fixes for Chinese Windows users (CJK username in path): 1. _cmd_safe_path(): replace APPDATA/LOCALAPPDATA paths with %APPDATA%/ %LOCALAPPDATA% env vars so generated .cmd files stay pure ASCII. cmd.exe on Chinese Windows chokes on UTF-8 CJK characters in batch files, breaking the set and cd commands. 2. uv-resolved pythonw in .cmd generation: uv venv's pythonw.exe is a shim that spawns the base python.exe (console app), which opens a visible Windows Terminal tab. Use _resolve_detached_python() in _build_gateway_cmd_script() so the generated .cmd uses the base pythonw.exe directly + passes venv site-packages via PYTHONPATH. 3. start() fallback: when schtasks /Run returns code 0 but no gateway process appears within 6s (common on Windows with slow task startup), fall back to _spawn_detached() instead of giving up.
Contributor
|
Thanks for documenting the localized Windows and uv-launcher failure modes. This is an automated hermes-sweeper review; current
The timeline’s related PR #41028 reports the same uv shim behavior; main now contains the corresponding production handling and test coverage. Closing as implemented on main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two bugs affect Chinese/Japanese/Korean Windows users whose home directory contains non-ASCII characters (e.g.
C:\Users\银\...):.cmdfile corruption —_build_gateway_cmd_script()writes raw UTF-8 CJK characters into the generated.cmdfile.cmd.exeon these Windows editions interprets the file using the system ANSI/OEM code page (e.g. GBK for zh-CN), which garbles thesetandcdcommands and silently breaks the Scheduled Task startup.Visible console window at startup —
_build_gateway_cmd_script()uses_derive_venv_pythonw(python_path)which returns the venv'spythonw.exe. On uv-created venvs,venv\Scripts\pythonw.exeis a shim that spawns the base interpreterpython.exe(a console-mode app), opening a visible Windows Terminal window.start()gives up too early — Whenschtasks /Runreturns exit code 0 but the gateway process does not appear within 6 seconds (common on slower machines),start()reports failure and returns without starting the gateway.Fix
_cmd_safe_path()— new helper that replacesAPPDATA/LOCALAPPDATAprefixed paths with their environment-variable form (%APPDATA%,%LOCALAPPDATA%), keeping the generated.cmdfiles pure ASCII regardless of the user's home directory encoding.uv-aware pythonw —
_build_gateway_cmd_script()now calls_resolve_detached_python()(the same function_spawn_detached()already uses) to get the true basepythonw.exefrom the uv cache, and passes the venv site-packages viaPYTHONPATH. No more window popping up.Graceful start() fallback — When
schtasks /Runsucceeds but no process appears within the 6-second window,start()now falls back to_spawn_detached()instead of silently giving up.Testing
Tested on Windows 11 Home zh-CN with username
银(a CJK character):hermes gateway start-> gateway starts silently, no console windowhermes gateway restart-> clean stop + silent start.cmdfile is pure ASCII (zero CJK characters)