launch: use native Windows Hermes config path (#16558)

This commit is contained in:
Bruce MacDonald
2026-06-05 17:29:19 -07:00
committed by GitHub
parent 25e0e81e12
commit a0099da2d1
2 changed files with 43 additions and 5 deletions
+25 -4
View File
@@ -452,12 +452,33 @@ func hermesWindowsBinaryFallbacks() []string {
return fallbacks
}
func hermesConfigPath() (string, error) {
func hermesHomePath() (string, error) {
if hermesHome := strings.TrimSpace(os.Getenv("HERMES_HOME")); hermesHome != "" {
return filepath.Clean(hermesHome), nil
}
if hermesGOOS == "windows" {
if localAppData := strings.TrimSpace(os.Getenv("LOCALAPPDATA")); localAppData != "" {
return filepath.Join(localAppData, "hermes"), nil
}
home, err := hermesUserHome()
if err != nil {
return "", err
}
return filepath.Join(home, "AppData", "Local", "hermes"), nil
}
home, err := hermesUserHome()
if err != nil {
return "", err
}
return filepath.Join(home, ".hermes", "config.yaml"), nil
return filepath.Join(home, ".hermes"), nil
}
func hermesConfigPath() (string, error) {
home, err := hermesHomePath()
if err != nil {
return "", err
}
return filepath.Join(home, "config.yaml"), nil
}
func hermesBaseURL() string {
@@ -465,11 +486,11 @@ func hermesBaseURL() string {
}
func hermesEnvPath() (string, error) {
home, err := hermesUserHome()
home, err := hermesHomePath()
if err != nil {
return "", err
}
return filepath.Join(home, ".hermes", ".env"), nil
return filepath.Join(home, ".env"), nil
}
func (h *Hermes) runGatewaySetupPreflight(args []string, runSetup func() error) error {
+18 -1
View File
@@ -423,19 +423,36 @@ func TestHermesConfigureMigratesLegacyManagedAliases(t *testing.T) {
func TestHermesPathsUsesLocalConfigPathForNativeWindowsHermes(t *testing.T) {
tmpDir := t.TempDir()
winHome := filepath.Join(tmpDir, "winhome")
localAppData := filepath.Join(tmpDir, "LocalAppData")
setTestHome(t, winHome)
withHermesPlatform(t, "windows")
withHermesUserHome(t, winHome)
t.Setenv("PATH", tmpDir)
t.Setenv("LOCALAPPDATA", localAppData)
writeFakeBinary(t, tmpDir, "hermes")
got := (&Hermes{}).Paths()
want := filepath.Join(winHome, ".hermes", "config.yaml")
want := filepath.Join(localAppData, "hermes", "config.yaml")
if len(got) != 1 || got[0] != want {
t.Fatalf("expected local config path %q, got %v", want, got)
}
}
func TestHermesPathsUsesHermesHomeOverride(t *testing.T) {
tmpDir := t.TempDir()
hermesHome := filepath.Join(tmpDir, "custom-hermes-home")
setTestHome(t, filepath.Join(tmpDir, "home"))
withHermesPlatform(t, "windows")
t.Setenv("HERMES_HOME", hermesHome)
t.Setenv("LOCALAPPDATA", filepath.Join(tmpDir, "LocalAppData"))
got := (&Hermes{}).Paths()
want := filepath.Join(hermesHome, "config.yaml")
if len(got) != 1 || got[0] != want {
t.Fatalf("expected HERMES_HOME config path %q, got %v", want, got)
}
}
func TestHermesCurrentModelRequiresHealthyManagedConfig(t *testing.T) {
tmpDir := t.TempDir()
setTestHome(t, tmpDir)