The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(install): report git errors when macOS developer tools are already present; wait under Hermes-Setup
unsupportedpastels9b3d61732a85
diff --git a/scripts/install.sh b/scripts/install.shindex 09d419cc1ec..c267866a40f 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -538,19 +538,25 @@ git_runs() { command -v git >/dev/null 2>&1 && git --version >/dev/null 2>&1; }# macOS ships /usr/bin/git as a stub until Apple's Command Line Tools are# installed: it is on PATH, but every call fails ("see man xcode-select").-# Prefer Homebrew (headless); else open Apple's install dialog and, with a-# terminal, wait for the user to finish it so the install continues in this run.+# Prefer Homebrew (headless); else open Apple's install dialog and wait for the+# user to finish it, so the install continues in this run.install_macos_git() {if command -v brew >/dev/null 2>&1; then- log "Installing git with Homebrew"- brew install git >/dev/null 2>&1 || true+ # Auto-update runs git (the broken stub here) and can take minutes.+ run_logged --may-fail "Installing git with Homebrew" env HOMEBREW_NO_AUTO_UPDATE=1 brew install git || truehash -rgit_runs && return 0fi- # Opens Apple's install dialog; harmless if it is already open or done.+ # Developer tools already present (e.g. an Xcode license never accepted):+ # no dialog will open, so let the caller report git's own error now.+ local _dev+ _dev="$(xcode-select -p 2>/dev/null)" && [ -d "$_dev" ] && return 0+ # Opens Apple's install dialog; harmless if it is already open.xcode-select --install >/dev/null 2>&1 || truelocal _remedy="Install Apple's Command Line Tools (run: xcode-select --install), then re-run this installer."- if [ "$NON_INTERACTIVE" = true ] || ! has_terminal; then+ # Hermes-Setup drives stages with --json: no stage timeout, a Cancel+ # button, and these log lines show as progress, so it waits too.+ if [ "$JSON" != true ] && { [ "$NON_INTERACTIVE" = true ] || ! has_terminal; }; thenfail "git needs Apple's Command Line Tools. $_remedy" git_missingfilog "git needs Apple's Command Line Tools: click Install in the macOS dialog and accept the license"diff --git a/tests/scripts/install/test_install_sh_git_prerequisite.py b/tests/scripts/install/test_install_sh_git_prerequisite.pyindex 6a95c4fdac5..8aa6b0f0fdc 100644--- a/tests/scripts/install/test_install_sh_git_prerequisite.py+++ b/tests/scripts/install/test_install_sh_git_prerequisite.py@@ -4,7 +4,7 @@ macOS ships /usr/bin/git as a stub until Apple's Command Line Tools areinstalled, so `command -v git` passes and the clone fails much later with"git clone failed; no checkout published". On macOS the installer gets gitfirst: Homebrew when present, else Apple's install dialog, waiting for it-when a terminal is attached.+unless a plain headless run cannot."""import os@@ -18,6 +18,11 @@ _STUB_ERR = ("xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), ""missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun")+_LICENSE_ERR = (+ "You have not agreed to the Xcode license agreements. "+ "Please run 'sudo xcodebuild -license' from within a Terminal window to review and agree to the Xcode "+ "and Apple SDKs license."+)_WORKING_GIT = "#!/bin/sh\necho 'git version 2.50.1'\n"@@ -27,9 +32,10 @@ def _exe(path: Path, body: str) -> None:path.chmod(0o755)-def _run_prerequisites(tmp_path: Path, *, git: str = "stub", interactive: bool = False,+def _run_prerequisites(tmp_path: Path, *, git: str = "stub", interactive: bool = False, json: bool = False,brew: bool = False, clt_finishes: bool = True):- """git: "stub" (fails until the CLT install finishes) or "working"."""+ """git: "stub" (fails until the CLT install finishes), "license" (developer+ tools present, Xcode license not accepted) or "working"."""bin_dir = tmp_path / "bin"brew_bin = tmp_path / "brew-bin"brew_bin.mkdir()@@ -37,22 +43,33 @@ def _run_prerequisites(tmp_path: Path, *, git: str = "stub", interactive: bool =calls = tmp_path / "calls.log"if git == "working":_exe(bin_dir / "git", _WORKING_GIT)+ elif git == "license":+ _exe(bin_dir / "git", f'#!/bin/sh\necho "{_LICENSE_ERR}" >&2\nexit 69\n')else:_exe(bin_dir / "git", f'#!/bin/sh\nif [ -f "{done}" ]; then echo "git version 2.39.5"; exit 0; fi\n'f'echo "{_STUB_ERR}" >&2\nexit 1\n')_exe(bin_dir / "curl", "#!/bin/sh\nexit 0\n")- _exe(bin_dir / "xcode-select", f'#!/bin/sh\necho "xcode-select $*" >> "{calls}"\nexit 1\n')+ # `-p` names the active developer directory only once the tools exist.+ dev_dir = tmp_path / "Xcode.app" / "Contents" / "Developer"+ if git == "license":+ dev_dir.mkdir(parents=True)+ _exe(bin_dir / "xcode-select",+ f'#!/bin/sh\nif [ "$1" = -p ]; then\n'+ f' if [ -d "{dev_dir}" ]; then echo "{dev_dir}"; exit 0; fi\n'+ f' echo "xcode-select: error: unable to get active developer directory" >&2; exit 2\nfi\n'+ f'echo "xcode-select $*" >> "{calls}"\nexit 1\n')# Each poll interval is where the user may finish Apple's dialog.finish = f'touch "{done}"\n' if clt_finishes else ""_exe(bin_dir / "sleep", f'#!/bin/sh\necho "sleep $*" >> "{calls}"\n{finish}exit 0\n')if brew:# Homebrew's bin precedes /usr/bin on PATH, as on a real Mac.- _exe(bin_dir / "brew", f'#!/bin/sh\necho "brew $*" >> "{calls}"\n'+ _exe(bin_dir / "brew", f'#!/bin/sh\necho "brew $* auto_update_off=$HOMEBREW_NO_AUTO_UPDATE" >> "{calls}"\n'f"printf '#!/bin/sh\\necho git version 2.51.0\\n' > \"{brew_bin}/git\"\n"f'chmod +x "{brew_bin}/git"\n')probe = ('source "$1" --manifest\n'f"NON_INTERACTIVE={'false' if interactive else 'true'}\n"+ f"JSON={'true' if json else 'false'}\n"f"has_terminal() {{ {'return 0' if interactive else 'return 1'}; }}\n""uv_bootstrap_target() { echo darwin-arm64; }\n""stage_prerequisites\n"@@ -77,17 +94,27 @@ def test_macos_stub_waits_for_clt_dialog_then_continues(tmp_path):assert calls == ["xcode-select --install", "sleep 5"][email protected]("macos")+def test_macos_stub_hermes_setup_json_run_waits_too(tmp_path):+ """Hermes-Setup runs stages with --non-interactive --json and no terminal."""+ result, calls = _run_prerequisites(tmp_path, interactive=False, json=True)++ assert result.returncode == 0, result.stderr+ assert "prerequisites ok" in result.stdout+ assert calls == ["xcode-select --install", "sleep 5"]++@pytest.mark.platforms("macos")def test_macos_stub_prefers_homebrew_without_dialog(tmp_path):result, calls = _run_prerequisites(tmp_path, interactive=True, brew=True)assert result.returncode == 0, result.stderrassert "prerequisites ok" in result.stdout- assert calls == ["brew install git"]+ assert calls == ["brew install git auto_update_off=1"]@pytest.mark.platforms("macos")-def test_macos_stub_non_interactive_fails_fast_with_remedy(tmp_path):+def test_macos_headless_non_interactive_fails_fast_with_remedy(tmp_path):result, calls = _run_prerequisites(tmp_path, interactive=False)assert result.returncode != 0@@ -106,6 +133,18 @@ def test_macos_stub_wait_gives_up_after_fifteen_minutes(tmp_path):assert "Still waiting for the Command Line Tools install (15m)" in result.stdout[email protected]("macos")+def test_macos_tools_present_but_git_fails_reports_git_error_without_waiting(tmp_path):+ """An unaccepted Xcode license: no dialog opens, so neither prompt nor wait."""+ result, calls = _run_prerequisites(tmp_path, git="license", interactive=True)++ assert result.returncode != 0+ assert "git is installed but cannot run" in result.stderr+ assert "sudo xcodebuild -license" in result.stderr+ assert "Command Line Tools" not in result.stderr+ assert calls == []++@pytest.mark.platforms("linux")def test_broken_git_on_linux_names_git_error_without_xcode(tmp_path):result, calls = _run_prerequisites(tmp_path)