The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pm): find conventional bash without a PATH entry
ethernetf0667b7048c7
diff --git a/pm/shell.py b/pm/shell.pyindex 6e9f7e4a5e0..f6a495640fd 100644--- a/pm/shell.py+++ b/pm/shell.py@@ -10,7 +10,8 @@ Resolution order:structurally guarantees it in a bundle; no hunt.2. Provisioned PATH: shutil.which("bash") — the store dirs are on theprocess PATH after pm.activate() ran.- 3. POSIX fallback table for non-bundle / daemon-launch PATH edge cases+ 3. Conventional Git for Windows under Program Files, even with an empty PATH.+ 4. POSIX fallback table for non-bundle / daemon-launch PATH edge cases(/usr/bin/bash, /bin/bash, $SHELL, /bin/sh). A systemd/cron-launchedgateway may have a minimal PATH and macOS /bin/bash is not on PATH bydefault, so `which` alone is not enough there.@@ -64,13 +65,13 @@ def bash() -> str | None:# Prefer a conventional install when one exists.if on_path and "windowsapps" not in on_path.lower():return on_path- if on_path and os.name == "nt":+ if os.name == "nt":programfiles = os.environ.get("ProgramFiles", r"C:\Program Files")for rel in (("Git", "bin", "bash.exe"), ("Git", "usr", "bin", "bash.exe")):cand = os.path.join(programfiles, *rel)if os.path.isfile(cand):return cand- return on_path # nothing conventional — the packaged one is all there is+ return on_path# POSIX fallbacks for minimal-PATH daemon launches / macOS /bin/bash.for candidate in (diff --git a/tests/pm/test_shell_discovery.py b/tests/pm/test_shell_discovery.pynew file mode 100644index 00000000000..a2129da1caf--- /dev/null+++ b/tests/pm/test_shell_discovery.py@@ -0,0 +1,36 @@+"""The local transport can use Git Bash without a PATH entry."""+import os+from pathlib import Path+import subprocess++import pytest++[email protected]("windows")+def test_local_transport_finds_conventional_bash_without_path(monkeypatch, tmp_path):+ from tools.environments.local import _find_bash++ program_files = Path(os.environ.get("ProgramFiles", r"C:\Program Files"))+ conventional = program_files / "Git/bin/bash.exe"+ if not conventional.is_file():+ pytest.skip("a conventional Git for Windows installation is required")++ monkeypatch.setenv("ProgramFiles", str(program_files))+ monkeypatch.setenv("HERMES_RUNTIME_DIR", str(tmp_path / "tools"))+ empty_bin = tmp_path / "empty-bin"+ alias_bin = tmp_path / "WindowsApps"+ empty_bin.mkdir()+ alias_bin.mkdir()+ (alias_bin / "bash.exe").write_bytes(b"unusable execution alias")+ monkeypatch.setenv("PATHEXT", ".EXE;.CMD")++ for directory in (empty_bin, alias_bin):+ monkeypatch.setenv("PATH", str(directory))+ selected = _find_bash()+ assert Path(selected) == conventional+ child = subprocess.run(+ [selected, "--noprofile", "--norc", "-c", "printf shell-ready"],+ cwd=tmp_path, capture_output=True, text=True, timeout=10,+ )+ assert child.returncode == 0, child.stderr+ assert child.stdout == "shell-ready"