Repository navigation
Fix gaia init version checks and MSI reliability - #478
Conversation
… MSI reliability - Rewrite _check_version_compatibility to accept newer versions silently instead of prompting for a downgrade (v9.3.4 >= v9.3.0 is fine) - Only prompt upgrade when installed version is below profile minimum - Fix misleading "Upgrade to v9.3.0?" prompt when it's actually a downgrade - Add registry-based ProductCode lookup for reliable MSI uninstall - Add wait_for_msi_mutex() to prevent msiexec collisions during upgrade - Handle MSI error 1618 (another installation in progress) - Try both minimal and full MSI variants as uninstall fallback - Fix gaia install --lemonade to use >= comparison instead of strict equality - Add 12 new unit tests for version compatibility, MSI mutex, and ProductCode
- Fix pylint protected-access: use public needs_install() instead of private _parse_version() in cli.py - Tighten registry match from "lemonade" to "lemonade server" to avoid matching unrelated products - Validate ProductCode as GUID format before passing to msiexec - Add log.warning when version parsing fails (aids debugging) - Show warning (not success) for newer-than-expected versions with helpful guidance message - Only print "Version is compatible" for exact match (avoid redundant message after warning) - Point users to lemonade-server.ai when installation completely fails - Restore emoji in cli.py success message
Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
@claude review this PR. |
|
Claude finished @kovtcharov-amd's task —— View job PR Review Complete
SummaryThis is a well-structured PR that fixes important UX issues with Review Findings🟢 Strengths
🟡 Suggestions (non-blocking)
🟢 Code Quality
Verified Behavior
VerdictLGTM - This PR is ready to merge. The suggestions above are minor improvements that can be addressed in follow-up work if desired. |
- Fix logger.py: use stream.reconfigure() instead of creating new TextIOWrapper instances, which detached buffers and broke pytest capture - Add debug logging to wait_for_msi_mutex exception handler - Include timeout value in MSI mutex warning message - Add mocked winreg tests for find_product_code registry lookup
…md#1940) Closes amd#316 Modern Lemonade (10.7+, including the 10.8.1 GAIA installs) removed the `lemonade-server` CLI — the server is now `LemonadeServer.exe --silent` on Windows (ctx size via the `LEMONADE_CTX_SIZE` env var) and a systemd `lemond` service on Linux. GAIA still hard-coded `lemonade-server serve` everywhere, so on a modern install `gaia init` reported a working Lemonade as **not installed**, and after any install it told the user to start the server by hand (amd#316's "never started it") — interactive mode could never auto-start because of an indentation bug that made the manual prompt unconditional. Now detection finds modern and legacy installs, and `gaia init` auto-starts the server in both interactive and CI modes, falling back to a prompt (showing the *correct* per-tooling command) only if auto-start fails. (amd#316's uninstall failure was previously fixed by amd#478; verified still working — the registry ProductCode lookup finds modern installs.) All changes route through one new stdlib-only primitive, `gaia.llm.lemonade_launcher` (`resolve_lemonade` / `get_installed_version` / `build_start_command`), consumed by the installer and `LemonadeClient` — legacy `lemonade-server` behavior is pinned byte-identical by tests, and CI's `LEMONADE_SERVER_PATH` override is honored first. ## Evidence (real-world, Windows 11 + Ryzen AI box, Lemonade 10.7.0) Tested by deploying this branch to the machine's editable GAIA install and running the real CLI over SSH. **Detection — before:** `main`'s check is `shutil.which("lemonade-server")`, which is `NOT ON PATH` on this modern install → "not installed" → forced reinstall over a working setup. **After:** ``` resolve_lemonade: found=True kind=modern client_path = C:\Users\...\AppData\Local\lemonade_server\bin\lemonade.exe server_launcher = C:\Users\...\AppData\Local\lemonade_server\bin\LemonadeServer.exe check_installation: installed=True version=10.7.0 build_start_command: argv=['C:\\Users\\...\\LemonadeServer.exe', '--silent'] env={'LEMONADE_CTX_SIZE': '32768'} ``` **Auto-start — `LemonadeServer.exe` stopped, then interactive `gaia init --profile minimal --skip-models` (stdin-driven, `yes` not set):** ``` Step 1/4: Checking Lemonade Server installation... ✓ Lemonade Server found: v10.7.0 Upgrade to v10.8.1? [y/N]: ✓ Continuing with v10.7.0 Step 2/4: Checking Lemonade Server... Lemonade Server is not running — starting it... | INFO | ..._auto_start_server | Starting Lemonade Server: C:\Users\...\LemonadeServer.exe --silent ✓ Server started and ready (waited 2s) Step 4/4: Verifying setup... ✓ Server health: OK ✓ Context size verified: 32768 tokens GAIA initialization complete! (exit code 0) ``` No "Please start Lemonade Server" prompt appeared; `LemonadeServer.exe` alive (pid captured) and `/api/v1/health` = 200 afterwards. The ctx-size env path is proven end-to-end by the Step-4 32768-token model preload. ## Test plan - [x] `python -m pytest tests/unit/test_init_command.py tests/unit/installer/ tests/unit/test_lemonade_launcher.py tests/test_lemonade_client.py -q` → 245 passed; the 4 failures are pre-existing environment artifacts (3 tests short-circuited by a live local Lemonade on :13305 — fail identically on `main` — plus 1 live-server integration test), none in changed code - [x] `python util/lint.py --all` → exit 0 - [x] Real-world Windows validation (above): modern detection + interactive auto-start + health + ctx preload - [ ] CI green (note: CI workflows start Lemonade externally, so the auto-start path itself is exercised by the real-world run above, not CI) <details> <summary>Reviewer notes — bundled behavior deltas & rationale</summary> - Tests were written first as a fixed contract (28 new/updated across 4 files), including falsifying assertions: `input()` never called on auto-start success, Popen env must retain the parent environment (merge, not replace), legacy argv pinned byte-identical, `LEMONADE_SERVER_PATH` honored before any PATH probe with modern-beats-stale-legacy precedence. - `launch_server()` now skips `kill_process_on_port` when a healthy server is already listening (never restarts a tray/systemd-managed server the user didn't ask to restart), raises an actionable error when no tooling is found, and its `background="terminal"` branch is argv-only (`CREATE_NEW_CONSOLE`) instead of a `shell=True` string. - `check_installation()` no longer returns installed=False on a version-probe timeout (that could trigger a pointless reinstall); a found install with a failed probe stays installed=True with a diagnostic error. `LemonadeInfo` shape and `find_product_code()` are unchanged (all five callers unaffected). - Windows legacy `launch_server` now passes `--no-tray` (aligning with what `gaia init` always did); `--log-level` is appended for legacy only (the modern launcher has no such flag — logged and ignored, not silently dropped). - User-facing "start/restart with:" hints render the resolved tooling's real command (env prefix + argv) instead of the removed `lemonade-server` CLI. - `_find_lemonade_server()` retained as a compat surface (delegates to the primitive) though it has no remaining callers. - Modern-Linux auto-start (`systemctl --user start lemond`) is best-effort and unit-tested only — the daemon is normally already running under systemd. - Follow-up (tracked separately): the PowerShell-side detection in `.github/actions/install-lemonade/action.yml` and `installer/scripts/*.ps1` duplicates this logic and has one stale search path; consolidating PS/Python detection is out of scope here. </details> --------- Co-authored-by: Tomasz Iniewicz <[email protected]> Co-authored-by: Tomasz Iniewicz <[email protected]>
Summary
gaia initno longer prompts to downgrade when a newer version is installed (e.g., v9.3.4 with v9.3.0 expected). Only prompts upgrade when below the profile's minimum version.wait_for_msi_mutex()between uninstall and install to prevent msiexec process conflicts (error 1618).gaia install --lemonade— Uses>=tuple comparison instead of strict string equality.Test plan
gaia initwith newer Lemonade version installed — should accept silentlygaia initwith older version above profile minimum — should accept with optional upgrade offergaia initwith version below profile minimum — should prompt upgrade (default: yes)gaia install --lemonadewith newer version — should report already installed