fix(terminal_ops): ssh 远程命令中避免重写 /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9/pip 路径

This commit is contained in:
JOJO 2026-06-24 17:33:12 +08:00
parent fd29b3b89c
commit d1a9a51bb8

View File

@ -414,6 +414,9 @@ class RunMixin:
execution_in_container = self._will_use_container(session_override) execution_in_container = self._will_use_container(session_override)
python_rewrite = self.container_python_cmd if execution_in_container else self.python_cmd python_rewrite = self.container_python_cmd if execution_in_container else self.python_cmd
pip_rewrite = self._derive_pip_from_python(python_rewrite) pip_rewrite = self._derive_pip_from_python(python_rewrite)
# 命令通过 ssh 在远程主机执行时,本地 Python/pip 路径对远程不适用,跳过重写
is_remote_ssh = command.lstrip().startswith("ssh ") or re.search(r"[;&|]\s*ssh\s", command) is not None
if not is_remote_ssh:
# 统一替换 python/python3为保障虚拟环境命中只替换独立单词 # 统一替换 python/python3为保障虚拟环境命中只替换独立单词
if re.search(r"\bpython3?\b", command): if re.search(r"\bpython3?\b", command):
command = re.sub(r"\bpython3?\b", python_rewrite, command) command = re.sub(r"\bpython3?\b", python_rewrite, command)