fix: use builtin cd in command wrapper to bypass shell aliases

Version managers like frum (Ruby), rvm, nvm, and others commonly alias
cd to a wrapper function that runs additional logic after directory
changes. When Hermes captures the shell environment into a session
snapshot, these aliases are preserved. If the wrapper function fails
in the subprocess context (e.g. frum not on PATH), every cd fails,
causing all terminal commands to exit with code 126.

Using builtin cd bypasses any aliases or functions, ensuring the
directory change always uses the real bash builtin regardless of
what version managers are installed.
This commit is contained in:
Konstantinos Karachalios 2026-04-14 10:18:11 +02:00 committed by Teknium
parent 3e95963bde
commit 435d86ce36

View file

@ -383,7 +383,7 @@ class BaseEnvironment(ABC):
quoted_cwd = (
shlex.quote(cwd) if cwd != "~" and not cwd.startswith("~/") else cwd
)
parts.append(f"cd {quoted_cwd} || exit 126")
parts.append(f"builtin cd {quoted_cwd} || exit 126")
# Run the actual command
parts.append(f"eval '{escaped}'")