Skip to content

fix(cli): ignore stale missing profile homes at startup - #59554

Open
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/stale-missing-profile-home
Open

fix(cli): ignore stale missing profile homes at startup#59554
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/stale-missing-profile-home

Conversation

@konsisumer

Copy link
Copy Markdown
Contributor

What changed and why

Per the reporter's clarification on July 6, 2026, the ghost-profile symptom was still reproducible on v0.18.0 and also showed up after rename. The concrete startup bug here was that Hermes trusted a stale HERMES_HOME pointing at .../profiles/<name> even after that profile directory had been deleted, so early startup work could recreate the missing profile before profile list or the dashboard finished booting.

This change updates _apply_profile_override() to:

  • keep trusting HERMES_HOME when it already points at a real profile directory
  • ignore a stale HERMES_HOME when it points at a missing named-profile path, falling back to normal root/default resolution instead of reviving the profile
  • ignore a stale active_profile entry when that named profile no longer exists, instead of aborting or recreating it

I also added regression coverage for both stale-startup cases so deleted/renamed profile paths do not come back just because Hermes starts.

How to test

  1. Run pytest -q tests/hermes_cli/test_apply_profile_override.py tests/hermes_cli/test_apply_profile_override_missing_profile.py.
  2. Reproduce the stale-env case manually: set HERMES_HOME to a deleted ~/.hermes/profiles/<name> path, run python -m hermes_cli.main profile list, and confirm Hermes stays on the default profile and does not recreate the missing directory.
  3. Reproduce the stale-active case manually: write a missing profile name into ~/.hermes/active_profile, run python -m hermes_cli.main profile list, and confirm Hermes warns and does not recreate profiles/<name>.

What platforms tested on

  • macOS (local worktree)
  • Python test run via pytest

Fixes #47368

Related: #45474

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles labels Jul 6, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused startup-path fix. Current main still returns for a profile-shaped HERMES_HOME without verifying the directory (hermes_cli/main.py:470-473) and exits when a missing active_profile target makes resolve_profile_env() raise (hermes_cli/main.py:491-510; hermes_cli/profiles.py:2219-2223). The PR changes those exact paths and adds direct regression coverage for both cases.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/profiles Multi-profile isolation, HERMES_HOME scoping labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles area/profiles Multi-profile isolation, HERMES_HOME scoping comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Desktop "Delete profile" silently fails and the profile keeps reappearing

3 participants