Skip to content

fix: gateway respects terminal.cwd config and update preserves WorkingDirectory - #11441

Closed
kagura-agent wants to merge 1 commit into
NousResearch:mainfrom
kagura-agent:fix/gateway-working-directory
Closed

fix: gateway respects terminal.cwd config and update preserves WorkingDirectory#11441
kagura-agent wants to merge 1 commit into
NousResearch:mainfrom
kagura-agent:fix/gateway-working-directory

Conversation

@kagura-agent

Copy link
Copy Markdown
Contributor

Fixes #11312

Problem

  1. Gateway ignores terminal.cwd config and TERMINAL_CWD/MESSAGING_CWD env vars — processes always run in the gateway's own directory
  2. hermes update overwrites the systemd service file, resetting any user-customized WorkingDirectory

Changes

Fix 1 — Gateway CWD (gateway/run.py)

  • After resolving TERMINAL_CWD env var, call os.chdir() so the gateway process uses the configured working directory

Fix 2 — Update preserves WorkingDirectory (hermes_cli/gateway.py)

  • Added _read_working_directory_from_unit() to extract custom WorkingDirectory from installed systemd units
  • generate_systemd_unit() now accepts working_dir_override parameter
  • refresh_systemd_unit_if_needed() and systemd_unit_is_current() preserve existing WorkingDirectory when it differs from PROJECT_ROOT

Tests

  • 9 new tests covering both fixes
  • All 133 related tests pass

…gDirectory

Two fixes for NousResearch#11312:
1. Gateway startup now calls os.chdir() after resolving TERMINAL_CWD so
   tools and child processes inherit the configured working directory.
2. refresh_systemd_unit_if_needed() reads the existing WorkingDirectory
   from the installed unit and preserves it when regenerating, so
   `hermes update` no longer overwrites user-customized paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kagura-agent

Copy link
Copy Markdown
Contributor Author

Closing to reduce PR volume — I had too many open PRs on this repo. The fix is still valid; happy to resubmit later if there's interest. Apologies for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gateway working directory config not respected, and resets after update.

1 participant