Skip to content

The agent that grows with you

fix(install): probe the command link directory for dependencies

fangliquan8c5a5deb7950
diff --git a/scripts/install.sh b/scripts/install.sh
index a53eef68962..096290221a4 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -1324,6 +1324,10 @@ check_network_prerequisites() {
}
install_system_packages() {
+ # setup_path persists this directory later, but dependency probes must also
+ # see commands that were pre-staged there during a fresh install.
+ local PATH="$(get_command_link_dir):$PATH"
+
# Detect what's missing
HAS_RIPGREP=false
HAS_FFMPEG=false
diff --git a/tests/scripts/install/test_install_sh_system_package_probe.py b/tests/scripts/install/test_install_sh_system_package_probe.py
new file mode 100644
index 00000000000..4adf9444f33
--- /dev/null
+++ b/tests/scripts/install/test_install_sh_system_package_probe.py
@@ -0,0 +1,49 @@
+"""Regression tests for command discovery during system-package setup."""
+
+import os
+import shutil
+import stat
+import subprocess
+from pathlib import Path
+
+import pytest
+
+
+REPO_ROOT = Path(__file__).resolve().parent.parent.parent.parent
+INSTALL_SH = REPO_ROOT / "scripts" / "install.sh"
+
+pytestmark = pytest.mark.skipif(shutil.which("bash") is None, reason="needs bash")
+
+
+def _write_executable(path: Path, body: str) -> None:
+ path.write_text(f"#!/bin/bash\n{body}\n")
+ path.chmod(path.stat().st_mode | stat.S_IXUSR)
+
+
+def test_system_package_probe_finds_commands_in_link_dir(tmp_path):
+ home = tmp_path / "home"
+ link_dir = home / ".local" / "bin"
+ path_dir = tmp_path / "path"
+ link_dir.mkdir(parents=True)
+ path_dir.mkdir()
+
+ _write_executable(link_dir / "rg", "printf 'ripgrep 14.1.0\\n'")
+ _write_executable(link_dir / "ffmpeg", "printf 'ffmpeg version 7.1 static\\n'")
+ _write_executable(path_dir / "head", "IFS= read -r line || true; printf '%s\\n' \"$line\"")
+ _write_executable(path_dir / "awk", "read -r first second third rest; printf '%s\\n' \"$third\"")
+
+ script = (
+ f'source "{INSTALL_SH}" --manifest >/dev/null\n'
+ 'OS=linux DISTRO=unknown install_system_packages\n'
+ 'printf "ripgrep=%s ffmpeg=%s\\n" "$HAS_RIPGREP" "$HAS_FFMPEG"\n'
+ )
+ result = subprocess.run(
+ ["bash", "-c", script],
+ capture_output=True,
+ text=True,
+ check=True,
+ env={**os.environ, "HOME": str(home), "PATH": str(path_dir)},
+ )
+
+ assert "ripgrep=true ffmpeg=true" in result.stdout
+ assert "not installed" not in result.stdout
\ No newline at end of file