You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With terminal.persistent_shell: true (the default), a single tool call that deletes the shell's current working directory wedges the terminal environment for the rest of the gateway's lifetime. Every subsequent subprocess.Popen raises FileNotFoundError: [Errno 2] on the cwd kwarg before the requested command runs.
Same root-cause class as #6607 and #4982, but in tools/environments/local.py — the executor for every shell command run by the agent.
In a single agent session with the local terminal backend:
mkdir -p /tmp/wedge-repro
cd /tmp/wedge-repro
rm -rf /tmp/wedge-repro
pwd
The final pwd fails with FileNotFoundError: [Errno 2] No such file or directory: '/tmp/wedge-repro'. Every terminal/file-tool call after this point fails the same way until the gateway is restarted.
Expected Behavior
A command leaving self.cwd at a non-existent path should not block all subsequent commands.
Actual Behavior
Observed Behavior
~/.hermes/logs/errors.log:
ERROR tools.terminal_tool: Execution failed after 3 retries -
Command: pwd - Error: FileNotFoundError: [Errno 2] No such file or directory:
'/tmp/wedge-repro' - Task: default, Backend: local
The path in the error is the cwd kwarg passed to Popen, not the command target. Stack trace:
File ".../tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
File ".../tools/environments/base.py", line 758, in execute
proc = self._run_bash(...)
File ".../tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(args, ..., cwd=self.cwd)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/wedge-repro'
terminal_tool retries 3× with ~5s timeout each, so each failure takes ~14–15s of wall clock.
Recovery requires restarting the gateway. There is no in-process recovery: cd / and similar fail with the same error because they too are Popen calls with the dead cwd.
Click to expand stack trace
```shell
2026-04-29 10:41:42,822 ERROR [20260429_104125_34b2b8] tools.terminal_tool: Execution failed after 3 retries - Command: mkdir -p /data/projects/test-project - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:41:43,833 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:41:44,847 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:41:45,859 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:41:46,869 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:42:02,288 ERROR [20260429_104125_34b2b8] tools.terminal_tool: Execution failed after 3 retries - Command: mkdir -p /data/projects/test-project 2>&1 || echo "mkdir failed"; ls -la /data/projects/ 2>&1 || echo "data dir not found" - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:42:17,467 ERROR [20260429_104125_34b2b8] tools.terminal_tool: Execution failed after 3 retries - Command: ls -la /data 2>&1 || echo "No /data directory" - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:42:32,880 ERROR [20260429_104125_34b2b8] tools.terminal_tool: Execution failed after 3 retries - Command: pwd && ls / - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:42:35,759 ERROR tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:42:35,766 ERROR tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:42:35,766 ERROR tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:42:35,769 ERROR tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:42:50,895 ERROR [20260429_104125_34b2b8] tools.terminal_tool: Execution failed after 3 retries - Command: echo "attempting basic command" - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:42:52,776 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:42:56,267 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:42:58,068 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:44:22,413 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: mkdir -p /data - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:44:37,950 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: df -h && ls -la / - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:44:53,991 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: pwd - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:45:10,255 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: mkdir -p /tmp/test-project - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:45:12,973 ERROR [20260429_102851_220f45] tools.checkpoint_manager: Git command skipped: git init (working directory not found: /tmp/test-project)
2026-04-29 10:45:12,984 ERROR [20260429_102851_220f45] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
Traceback (most recent call last):
File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool
result = file_ops.write_file(path, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file
mkdir_result = self._exec(mkdir_cmd)
^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec
result = self.env.execute(command, cwd=effective_cwd, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute
proc = self._run_bash(
^^^^^^^^^^^^^^^
File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash
proc = subprocess.Popen(
^^^^^^^^^^^^^^^^^
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project'
2026-04-29 10:45:29,233 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: cd / && pwd - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:45:45,089 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: ls -la / | grep data - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:46:34,413 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: pwd - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:46:50,956 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: ./test-project - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:47:15,015 INFO agent.auxiliary_client: Auxiliary auto-detect: using main provider lmstudio (hermes-4.3-36b)
2026-04-29 10:49:06,425 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: echo "test" > /tmp/test.txt - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:49:23,406 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: mkdir -p /data - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local
2026-04-29 10:56:42,964 INFO agent.auxiliary_client: Auxiliary auto-detect: using main provider lmstudio (hermes-4.3-36b)
```
### Operating System
Ubuntu 24.04
Python Version
3.12.13
Hermes Version
0.11.0
Additional Logs / Traceback (optional)
Root Cause Analysis (optional)
Root Cause
In tools/environments/local.py:
Line 356–367: _run_bash passes cwd=self.cwd to subprocess.Popen.
Line 392–400: _update_cwd assigns self.cwd = cwd_path from a post-command marker file with no existence check:
When bash deletes its own cwd, it stays alive with an unlinked directory. The marker writes back the now-deleted path, self.cwd is updated to it, and every subsequent Popen fails with ENOENT before exec.
Proposed Fix (optional)
Workaround
Avoid cd <dir> followed by rm -rf <dir> in the same persistent_shell session. Use absolute paths for delete, or cd .. first. Or set terminal.persistent_shell: false.
Bug Description
With
terminal.persistent_shell: true(the default), a single tool call that deletes the shell's current working directory wedges the terminal environment for the rest of the gateway's lifetime. Every subsequentsubprocess.PopenraisesFileNotFoundError: [Errno 2]on the cwd kwarg before the requested command runs.Same root-cause class as #6607 and #4982, but in
tools/environments/local.py— the executor for every shell command run by the agent.Environment
ff687c01(v2026.4.23-948-gff687c01)local,persistent_shell: true,lifetime_seconds: 300Related
checkpoint_manager._run_gitcli.pyviaos.getcwd()Steps to Reproduce
In a single agent session with the local terminal backend:
The final
pwdfails withFileNotFoundError: [Errno 2] No such file or directory: '/tmp/wedge-repro'. Every terminal/file-tool call after this point fails the same way until the gateway is restarted.Expected Behavior
A command leaving
self.cwdat a non-existent path should not block all subsequent commands.Actual Behavior
Observed Behavior
~/.hermes/logs/errors.log:The path in the error is the cwd kwarg passed to Popen, not the command target. Stack trace:
terminal_tool retries 3× with ~5s timeout each, so each failure takes ~14–15s of wall clock.
Recovery requires restarting the gateway. There is no in-process recovery:
cd /and similar fail with the same error because they too are Popen calls with the dead cwd.Affected Component
Tools (terminal, file ops, web, code execution, etc.)
Messaging Platform (if gateway-related)
N/A (CLI only)
Debug Report
Click to expand stack trace
```shell 2026-04-29 10:41:42,822 ERROR [20260429_104125_34b2b8] tools.terminal_tool: Execution failed after 3 retries - Command: mkdir -p /data/projects/test-project - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:41:43,833 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:41:44,847 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:41:45,859 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:41:46,869 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:42:02,288 ERROR [20260429_104125_34b2b8] tools.terminal_tool: Execution failed after 3 retries - Command: mkdir -p /data/projects/test-project 2>&1 || echo "mkdir failed"; ls -la /data/projects/ 2>&1 || echo "data dir not found" - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:42:17,467 ERROR [20260429_104125_34b2b8] tools.terminal_tool: Execution failed after 3 retries - Command: ls -la /data 2>&1 || echo "No /data directory" - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:42:32,880 ERROR [20260429_104125_34b2b8] tools.terminal_tool: Execution failed after 3 retries - Command: pwd && ls / - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:42:35,759 ERROR tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:42:35,766 ERROR tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:42:35,766 ERROR tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:42:35,769 ERROR tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:42:50,895 ERROR [20260429_104125_34b2b8] tools.terminal_tool: Execution failed after 3 retries - Command: echo "attempting basic command" - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:42:52,776 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:42:56,267 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:42:58,068 ERROR [20260429_104125_34b2b8] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:44:22,413 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: mkdir -p /data - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:44:37,950 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: df -h && ls -la / - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:44:53,991 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: pwd - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:45:10,255 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: mkdir -p /tmp/test-project - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:45:12,973 ERROR [20260429_102851_220f45] tools.checkpoint_manager: Git command skipped: git init (working directory not found: /tmp/test-project) 2026-04-29 10:45:12,984 ERROR [20260429_102851_220f45] tools.file_tools: write_file error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' Traceback (most recent call last): File "/data/projects/hermes-agent/tools/file_tools.py", line 827, in write_file_tool result = file_ops.write_file(path, content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 713, in write_file mkdir_result = self._exec(mkdir_cmd) ^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/file_operations.py", line 383, in _exec result = self.env.execute(command, cwd=effective_cwd, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/base.py", line 758, in execute proc = self._run_bash( ^^^^^^^^^^^^^^^ File "/data/projects/hermes-agent/tools/environments/local.py", line 356, in _run_bash proc = subprocess.Popen( ^^^^^^^^^^^^^^^^^ File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/home/nemy/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' 2026-04-29 10:45:29,233 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: cd / && pwd - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:45:45,089 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: ls -la / | grep data - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:46:34,413 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: pwd - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:46:50,956 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: ./test-project - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:47:15,015 INFO agent.auxiliary_client: Auxiliary auto-detect: using main provider lmstudio (hermes-4.3-36b) 2026-04-29 10:49:06,425 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: echo "test" > /tmp/test.txt - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:49:23,406 ERROR [20260429_102851_220f45] tools.terminal_tool: Execution failed after 3 retries - Command: mkdir -p /data - Error: FileNotFoundError: [Errno 2] No such file or directory: '/data/projects/test-project' - Task: default, Backend: local 2026-04-29 10:56:42,964 INFO agent.auxiliary_client: Auxiliary auto-detect: using main provider lmstudio (hermes-4.3-36b) ```Ubuntu 24.04
Python Version
3.12.13
Hermes Version
0.11.0
Additional Logs / Traceback (optional)
Root Cause Analysis (optional)
Root Cause
In
tools/environments/local.py:Line 356–367:
_run_bashpassescwd=self.cwdtosubprocess.Popen.Line 392–400:
_update_cwdassignsself.cwd = cwd_pathfrom a post-command marker file with no existence check:When bash deletes its own cwd, it stays alive with an unlinked directory. The marker writes back the now-deleted path,
self.cwdis updated to it, and every subsequent Popen fails with ENOENT before exec.Proposed Fix (optional)
Workaround
Avoid
cd <dir>followed byrm -rf <dir>in the same persistent_shell session. Use absolute paths for delete, orcd ..first. Or setterminal.persistent_shell: false.Possible Fixes
Two possible fixes:
Validate before Popen in
_run_bash: ifPath(self.cwd).is_dir()is false, fall back to a known-good cwd (~, orterminal.cwdfrom config) and log a warning. Mirrors_safe_getcwd()in fix: guard os.getcwd() against deleted CWD (FileNotFoundError) #4982.Validate at update time in
_update_cwd: only assignself.cwd = cwd_pathifPath(cwd_path).is_dir(). Keep the previous cwd otherwise.(1) also handles the case where the cwd is deleted out-of-band by another process.
Are you willing to submit a PR for this?