Skip to content

fix(cli): prefer launch cwd for local sessions - #19218

Closed
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/cli-tui-launch-cwd-19214
Closed

fix(cli): prefer launch cwd for local sessions#19218
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/cli-tui-launch-cwd-19214

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

Summary

Fixes #19214.

Interactive local CLI/TUI sessions should run from the directory where the user launched Hermes. A persisted terminal.cwd from full setup or hermes setup terminal should not silently pin cd ~/project && hermes back to an old directory, and a stale .env TERMINAL_CWD should not do that either.

This PR:

  • forces local interactive CLI/TUI config loading to bridge TERMINAL_CWD=os.getcwd()
  • keeps gateway/daemon runtime on configured terminal.cwd by marking the gateway process before lazy CLI imports
  • preserves the existing gateway lazy-import guard for pre-resolved cwd values
  • expands cwd-resolution tests to cover interactive config, stale env, and gateway runtime behavior

Verification

  • scripts/run_tests.sh tests/cli/test_cwd_env_respect.py tests/gateway/test_config_cwd_bridge.py tests/hermes_cli/test_config_env_expansion.py
    • 45 passed, 4 warnings

@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 comp/gateway Gateway runner, session dispatch, delivery labels May 3, 2026
@teknium1

teknium1 commented May 7, 2026

Copy link
Copy Markdown
Contributor

Thanks! Closing as redundant — main already forces os.getcwd() for local backend in load_cli_config (no HERMES_GATEWAY_PROCESS marker needed, main's simpler approach achieves the same end result: interactive CLI tools run from the shell's cwd, gateway has its own config bridge in gateway/run.py).

If you've hit a scenario where gateway still rewrites TERMINAL_CWD during a lazy cli.py import (the issue #10817 case), please file a fresh reproducer.

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

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terminal.cwd config is a foot-gun: CLI/TUI should always use launch directory

3 participants