fix(desktop): read HERMES_HOME from the Windows registry when env is stale - #45628
Closed
lEWFkRAD wants to merge 1 commit into
Closed
fix(desktop): read HERMES_HOME from the Windows registry when env is stale#45628lEWFkRAD wants to merge 1 commit into
lEWFkRAD wants to merge 1 commit into
Conversation
…stale A desktop app launched from Explorer inherits the environment block captured at login, so a HERMES_HOME set via `setx` after login is absent from process.env even though the CLI (a fresh shell) sees it. The desktop's resolveHermesHome() consulted only process.env, so on Windows the backend silently fell back to %LOCALAPPDATA%\hermes and reported "No inference provider configured" despite a valid configured home — while the identical CLI config worked (NousResearch#45471). It also cascades: both .env locations and the Settings panel resolve relative to that wrong home. Add a Windows-only registry fallback: when process.env.HERMES_HOME is unset, read the live User-scoped value from HKCU\Environment before defaulting to LOCALAPPDATA. Factored into a dependency-free, injectable-exec helper (windows-user-env.cjs) with unit tests, mirroring backend-env.cjs. The fallback is gated (Windows-only, only when the env var is absent), so the common path is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
|
This was merged in with #46772 |
Contributor
Author
Well, isn't that nice |
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.
What does this PR do?
On Windows, Hermes Desktop shows "No inference provider configured" even when
HERMES_HOMEand the provider/.envare correctly configured and the CLI works with the identical setup (#45471).Root cause: a GUI app launched from Explorer inherits the environment block captured at login, so a
HERMES_HOMEset viasetxafter login is absent fromprocess.env— even though a fresh shell (and the CLI) sees it immediately. The desktop'sresolveHermesHome()(electron/main.cjs) consulted onlyprocess.env.HERMES_HOME, so it silently fell back to%LOCALAPPDATA%\hermes, where there's no config/.env. The spawn itself is fine —startHermes()already pinsHERMES_HOMEand inheritsprocess.env— but it pins the wrong value. Because everything downstream (both.envlookup locations and the Settings panel) resolves relative to that home, all three configuration paths the reporter tried failed at once.The repo already acknowledges this fragility —
main.cjsnotes "install.ps1 sets HERMES_HOME via setx; the desktop can't reliably do that, so we set it inline for every spawn." This PR closes the remaining gap.Related Issue
Fixes #45471
Type of Change
Changes Made
apps/desktop/electron/windows-user-env.cjs(new) — dependency-free helper reading a User-scoped env var fromHKCU\Environmentviareg query, withreg-output parsing and%VAR%expansion. Pure functions + an injectableexecso it's unit-testable without spawning, mirroringbackend-env.cjs.apps/desktop/electron/main.cjs—resolveHermesHome()now consultsreadWindowsUserEnvVar('HERMES_HOME')on Windows whenprocess.env.HERMES_HOMEis unset, before the%LOCALAPPDATA%\hermesdefault. Gated: Windows-only, fallback-only — the common path (env var present, or non-Windows) is untouched.apps/desktop/electron/windows-user-env.test.cjs(new) — unit tests for the parser, the%VAR%expander, and the reader (off-Windows no-spawn, query shape, expansion, reg-exits-nonzero, empty value).apps/desktop/package.json— register the new test intest:desktop:platforms(scripts-only; no dependency/lockfile change).How to Test
Verified on Windows 11 against the live registry — the helper reads real
HKCU\Environmentvalues, including the exact target var:This confirms the mechanism picks up a
setx-configuredHERMES_HOMEthat a GUI-launchedprocess.envwould miss.Checklist
Code
fix(desktop): …)pytest tests/ -qand all tests pass — N/A: JS/Electron change. Rannode --test electron/windows-user-env.test.cjs→ 10 pass, andnpm run test:desktop:platforms→ 164/165 (the one failure,desktop background child processes opt into hidden Windows consolesinwindows-child-process.test.cjs, is pre-existing onmainand unrelated to this change — it's untouched here)windows-user-env.test.cjs)HKCU\Environmentread)Documentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys — N/A: no config keysCONTRIBUTING.md/AGENTS.mdif I changed architecture/workflows — N/AScreenshots / Logs
See How to Test above (
node --testoutput + live registry read).