Skip to content

fix(local): respect configured cwd in init_session() (salvage #12983)#14242

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-17b001fb
Apr 23, 2026
Merged

fix(local): respect configured cwd in init_session() (salvage #12983)#14242
teknium1 merged 2 commits into
mainfrom
hermes/hermes-17b001fb

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvages #12983 by @WuTianyi123 onto current main.

LocalEnvironment._run_bash builds a subprocess.Popen without passing cwd, so every bash invocation — including the initial init_session bootstrap — inherits the Python process's current directory instead of the caller-configured self.cwd. For regular commands this is masked by the _wrap_command prefix (builtin cd $cwd ...), but init_session bootstrap runs a raw pwd -P > cwd_file without a wrapping cd — it records the wrong starting directory.

One-line fix: pass cwd=self.cwd to Popen. self.cwd is always set (__init__ defaults to os.getcwd() when no value provided), so no regression risk for callers that don't configure an explicit cwd.

Attribution note

Original commit's author email was an unlinked Gmail address, so the commit was re-authored to @WuTianyi123's GitHub noreply email so the contribution attributes to their profile. All code is @WuTianyi123's.

Closes #12983.

WuTianyi123 and others added 2 commits April 22, 2026 17:54
LocalEnvironment._run_bash() spawned subprocess.Popen without a cwd
argument, so init_session()'s pwd -P ran in the gateway process's
startup directory and overwrote self.cwd. Pass cwd=self.cwd so the
initial snapshot captures the user-configured working directory.

Tested:
- pytest tests/ -q (255 env-related tests passed)
- Full suite: 13,537 passed; 70 pre-existing failures unrelated to local env
@teknium1 teknium1 merged commit e511429 into main Apr 23, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-17b001fb branch April 23, 2026 00:55
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists backend/local Local shell execution tool/terminal Terminal execution and process management labels Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/local Local shell execution P2 Medium — degraded but workaround exists tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants