Skip to content

fix: make Hermes launcher survive home directory changes - #65304

Draft
Fe2-O3 wants to merge 1 commit into
NousResearch:mainfrom
Fe2-O3:fix/home-agnostic-launcher
Draft

fix: make Hermes launcher survive home directory changes#65304
Fe2-O3 wants to merge 1 commit into
NousResearch:mainfrom
Fe2-O3:fix/home-agnostic-launcher

Conversation

@Fe2-O3

@Fe2-O3 Fe2-O3 commented Jul 16, 2026

Copy link
Copy Markdown

This fixes Hermes launcher behavior for users who change usernames, restore a profile onto a new machine, or otherwise end up with a different home directory than the one used at install time.

Today the installer-generated launcher can keep pointing at an old absolute path, which breaks hermes before the app even starts. That forces users to understand and repair internal launcher paths just to get back to a working state.

This change makes the launcher home-agnostic so it resolves from the current environment instead of assuming one fixed user directory.

Why this matters:

  • Users should not have to know where the launcher lives internally.
  • A username or machine change should not silently break the CLI.
  • The fix belongs in the installer-generated launcher, not as an isolated uninstall workaround.

Scope:

  • scripts/install.sh launcher generation
  • launcher regression tests

Verification:

  • Ran the targeted regression tests with uv run --with pytest python -m pytest tests/test_install_sh_pythonpath_sanitization.py tests/test_install_sh_symlink_stomp.py
  • Confirmed both tests pass.

@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 sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 16, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to closed, unmerged #65292, which carried the same launcher-path change. This is the active submission for the home-directory migration fix.

@Fe2-O3

Fe2-O3 commented Jul 16, 2026

Copy link
Copy Markdown
Author

This is complementary to the recent $HOME-hardening work rather than overlapping with it: #65286 stops runtime terminal.cwd from persisting $HOME, and #65250 / #65165 stop skills resolving under a stale home. This PR closes the remaining gap — the installer-generated launcher in scripts/install.sh bakes an absolute home path, which breaks hermes at startup after a username change, profile restore, or move to a new machine.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for identifying a real launcher-migration gap: current main expands the installer-time HERMES_BIN into the shim at scripts/install.sh:1604 and scripts/install.sh:1642.

Problems

  • scripts/install.sh:1642 replaces the resolved executable with $HOME/.hermes/hermes-agent/venv/bin/hermes. That bypasses documented explicit install directories (scripts/install.sh:404-408), root FHS installs at /usr/local/lib/hermes-agent (scripts/install.sh:427-438), and the USE_VENV=false PATH branch (scripts/install.sh:1603-1611). Those supported installations would launch the wrong or nonexistent executable.
  • The changed assertions in tests/test_install_sh_pythonpath_sanitization.py:30 and tests/test_install_sh_symlink_stomp.py:120 check a literal generated string rather than executing the launcher after a home change. AGENTS.md:1370-1391 prohibits source-shape tests for this reason.

Suggested changes

  • Preserve all existing layout-resolution modes while adding runtime resolution for a relocated default installation.
  • Add a behavioral launcher test using controlled old/new homes, plus coverage for a non-default install mode.

Automated hermes-sweeper review.

Comment thread scripts/install.sh Outdated
unset PYTHONPATH
unset PYTHONHOME
exec "$HERMES_BIN" "\$@"
exec "\$HOME/.hermes/hermes-agent/venv/bin/hermes" "\$@"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HERMES_BIN is deliberately resolved above for explicit --dir/HERMES_INSTALL_DIR, root-FHS, and --no-venv installs. Replacing it with the default per-home venv path breaks those supported layouts; retain their resolution while making only the default relocated layout dynamic.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jul 16, 2026
setup_path() baked the install-time absolute $HERMES_BIN into the launcher
shim, so `hermes` broke outright once the user's home moved — a username
change, a profile restored onto a new machine, or any migration left the shim
exec'ing a path that no longer existed, before the app ever started. Users had
to understand and repair internal launcher paths just to get back to a working
install.

Emit a $HOME-relative exec target when $HERMES_BIN resolves under the
installing user's home, so the path is expanded by the shim at launch time
rather than frozen at install time. Installs outside $HOME keep their absolute
resolved path, preserving every other supported layout: an explicit --dir /
$HERMES_INSTALL_DIR, the root FHS layout under /usr/local/lib/hermes-agent,
and USE_VENV=false installs whose $HERMES_BIN came from PATH.

Tests execute the generated launcher rather than asserting on install.sh's
source text (AGENTS.md: "Never read source code in tests"): one installs under
a controlled home, physically relocates it, and re-runs the launcher; one
covers a non-default out-of-home install and asserts the absolute path
survives a HOME change. Both fail against the respective broken variants.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Fe2-O3
Fe2-O3 force-pushed the fix/home-agnostic-launcher branch from e90b65b to 9487c67 Compare July 16, 2026 17:29
@Fe2-O3

Fe2-O3 commented Jul 16, 2026

Copy link
Copy Markdown
Author

Updated — both review points addressed, and the branch is rebased onto current main (it was 181 commits behind; AGENTS.md flags the stale-branch merge hazard). Squashed to a single commit.

Layout resolution preserved. The shim now rewrites to a $HOME-relative exec target only when $HERMES_BIN resolves under the installing user's home, so it expands at launch time instead of being frozen at install time. Every install that does not live under $HOME keeps its absolute resolved path — explicit --dir / $HERMES_INSTALL_DIR, the root FHS layout under /usr/local/lib/hermes-agent, and USE_VENV=false installs whose $HERMES_BIN came from PATH are all unaffected.

Behavioral tests, no source-shape assertions. tests/test_install_sh_launcher_home_migration.py drives the real setup_path() shim-write block, physically relocates the home directory, then executes the launcher; a second test covers a non-default out-of-home install and asserts the absolute path survives a HOME change. The PYTHONPATH test now executes the generated shim with a poisoned PYTHONPATH/PYTHONHOME instead of grepping install.sh.

Both tests were checked against the variants they guard, so neither is vacuous: the migration test fails against exec "$HERMES_BIN" (current main), and the out-of-home test fails against the previous hardcoded $HOME/.hermes/... target. Full tests/test_install_sh_*.py suite: 35 passed.

@GottZ GottZ left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated by AI during triage.

Summary

Two PRs address the launcher failure caused by embedding an install-time home path: #65292 replaces it with one fixed $HOME layout, while #65304 conditionally makes only in-home installs relocatable and preserves other supported layouts.

Related pull requests

  • #65292 [closed] duplicate — (+3/-3) — superseded by #65304: It targets the reported stale-home launcher path, but hard-codes $HOME/.hermes/hermes-agent/venv/bin/hermes, breaking explicit install directories, root FHS installs, and USE_VENV=false PATH-based installs; although closed unmerged, it remains relevant as the earlier duplicate implementation.
  • #65304 related — (+240/-9) — preferred fix: The diff converts HERMES_BIN to a runtime $HOME-relative target only when it was installed beneath the original home, retains absolute targets otherwise, and adds behavioral coverage for home relocation, out-of-home layouts, environment sanitization, and argument forwarding. This directly addresses the contributor keep_open review on #65304, including its layout-preservation and behavioral-test concerns.

Duplicates

#65292 and #65304 address the same launcher home-migration defect, but #65304 supersedes #65292 with layout-aware resolution and behavioral regression tests.

Suggested consolidation

Merge #65304 as the complete, review-addressed implementation; keep #65292 closed as a superseded duplicate.

Complex graph

flowchart LR
    classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
    classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
    classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
    classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
    classDef best stroke-width:3px,stroke:#b45309
    classDef target stroke-width:3px,stroke:#4338ca
    subgraph Dup65292 ["PRs duplicating each other"]
        P65292["PR #65292 (closed)"]
        P65304["PR #65304 (open)"]
    end
    class P65292 closed
    class P65304 open
    class P65304 target
    click P65292 "https://github.com/NousResearch/hermes-agent/pull/65292"
    click P65304 "https://github.com/NousResearch/hermes-agent/pull/65304"
Loading

Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).

Cross-PR triage: Reviewed 2 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 14 kB of PR diffs, 2 kB of issue/PR text, 3 kB of discussion (5 comments), 1 verify verdict. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

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 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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants