Repository navigation
fix(probe): re-exec through a child on Windows so spaced interpreter paths work - #57
Conversation
…paths work
`_use_gateway_python()` hands the probe over to a backend interpreter with
`os.execv(executable, [executable, <script>, *argv])`. On Windows, CreateProcess
splits an unquoted argv[0] at the first space, so an interpreter installed under
"Program Files" is launched as "D:\Program" and the rest is read as the script
name:
D:\Program: can't open file 'D:\Program Files\...\python.exe'
The child exits 0 with an empty stdout, so Desktop's pinnedPage() runs
JSON.parse('') and shows "probe returned non-JSON" with no quota windows at all.
It only fires when the launch path differs from the candidate list - e.g. when
probe.py is started through a hermes-agent/.venv junction whose real location is
installs/<id>/environments/<hash>/venv - which is why command-line tests on the
real path look fine.
Windows now re-execs as a child (subprocess.run) and forwards its exit status;
POSIX keeps os.execv.
Verified on Windows 11 with Hermes under D:\Program Files\Hermes: before the
change --gateway-runtime printed nothing and exit 0; after it prints the full
provider JSON array, and the remaining probe flags/environment survive the
handoff.
3c75db5 to
da30e68
Compare
sys.platform == "win32" matches the probe's other Windows checks and lets tests pin the platform without patching os.name, which pathlib and the venv path logic also read.
A spaced interpreter path must reach subprocess.run intact and the child's exit status must be forwarded. The existing os.execv tests now pin a POSIX platform so the suite gives the same result on Windows hosts.
Picks up the sys.platform check so build_catalog.py --check passes.
Credits @jorisquintano for Adolanium#56 and @Iversondwx for Adolanium#57.
|
Merged, thank you @Iversondwx, and welcome! Tracing the empty stdout back to the I added a few commits on top of yours before merging:
All the workflow steps pass in CI and locally. I didn't have an install under Catalog installs are pinned to 0.2.27, so they get this once a new release is pinned upstream. Until then, you can copy One small thing: your commits are authored as |
|
Confirmed on Tested on Windows 11 with Hermes installed under
One data point for Until a catalog release pins this, I'll keep those two copies on |
|
Thanks @Iversondwx. Checking both copies by hash and running the probe from both locations settles it. The Windows handoff works on a real The test failure you saw was real, and it came from the missing The catalog release still has to be cut and pinned upstream before |
Problem
_use_gateway_python()hands the probe over to a backend interpreter with:On Windows,
CreateProcesssplits an unquotedargv[0]at the first space. An interpreter installed underD:\Program Files\...is launched asD:\Program, and the rest of the path is then read as the script name:The child exits 0 with an empty stdout, so Desktop's
pinnedPage()runsJSON.parse('')and renders "probe returned non-JSON" with no quota windows at all.It only fires when the launch path differs from the candidate list — for example when
probe.pyis started through ahermes-agent/.venvjunction whose real location isinstalls/<id>/environments/<hash>/venv. Starting from the real path short-circuits atos.path.normcase(executable) == os.path.normcase(sys.executable)and never reachesos.execv, which is why running the probe from a shell on the real path looks fine.Fix
On Windows, re-exec as a child (
subprocess.run([executable, *argv])) and forward its exit status withos._exit. POSIX keepsos.execv.Verification (Windows 11, Hermes installed under
D:\Program Files\Hermes)python probe.py --gateway-runtime→ empty stdout, exit 0, Desktop shows "probe returned non-JSON".python -m py_compile probe.pypasses.probe.pyonly.