Skip to content

fix(installer): install and suggest packages that work on the installer's venv - #4617

Merged
kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/installer-venv-pip
Oct 4, 2026
Merged

kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/installer-venv-pip

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

On a machine set up with the one-line installer, gaia init reported "initialization complete" while document Q&A was broken: the installer's Python environment has no pip and is never activated, so every way init tried to install the [rag] extras failed, and init swallowed the error. Now init installs with uv pip install --python <GAIA's python> (or pip where the environment has it), and a failed install fails gaia init with the installer's error and the exact command to retry. The "install the chat agent" and Agent UI "missing dependencies" hints print that same working command instead of one that errors. The completion screen also stops telling pip users to run gaia-tui, which only the installer provides; it now points them at the installer.

Test plan

  • pytest tests/unit/installer/test_init_pip_extras.py tests/unit/agents/test_install_hints.py tests/unit/installer/test_init_default_profile.py: checks the exact argv (--python flag present; uv vs pip chosen by what exists), that a failed install makes gaia init exit 1 with stderr shown, and that the gaia-tui line appears only when it is on PATH
  • Broader unit suites (tests/unit/installer/, tests/unit/agents/, test_init_command.py, test_webui_build.py, test_amd_gaia_urls.py) pass with isolated GAIA_HOME/GAIA_DAEMON_HOME
  • Checked against a real uv venv: python -m pip fails with "No module named pip", bare uv pip install fails with "No virtual environment found", and the --python form installs
  • On a fresh curl -fsSL https://amd-gaia.ai/install.sh | sh box, gaia init installs [rag], and python -c "import faiss" works in ~/.gaia/venv
  • Same on Windows via install.ps1

…er's venv

The one-line installer builds ~/.gaia/venv with `uv venv`, which has no pip
and is never activated. On that venv `gaia init` could not install the [rag]
extras (bare `uv pip install` finds no venv; `python -m pip` does not exist),
swallowed every failure and still printed "initialization complete" with
document Q&A broken. The agent-install and Agent UI hints printed the same
dead commands, and init told pip users to run `gaia-tui`, which only the
installer provides.

- One resolver picks the installer that can write into this interpreter:
  `python -m pip` when pip is importable, else `uv pip install --python
  <sys.executable>`; with neither it raises with a remedy.
- `gaia init` installs extras through it and exits non-zero on failure,
  showing the installer's stderr and the exact retry command.
- Agent-install and Agent UI hints print the same resolved command.
- The completion screen names `gaia-tui` only when it is on PATH, and
  otherwise points at the installer.
@github-actions github-actions Bot added documentation Documentation changes cli CLI changes tests Test changes agents labels Oct 4, 2026
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

On a one-line-installer machine, gaia init used to say "initialization complete" even when document Q&A was broken: every install attempt failed against the installer's pip-less, never-activated environment, and the failure was swallowed. This PR fixes that. It picks the one installer that can actually write into GAIA's own Python (pip where it exists, otherwise uv … --python <that interpreter>), and fails init with the real error plus a retry command. The UI and chat-agent hints now print that same working command. The logic is right and the tests pin the exact command that runs. Nothing blocks merge.

Worth tidying, none of it blocking:

  • The install no longer has a time limit, so a stalled download can hang gaia init with no output. Give it a generous timeout that fails loudly.
  • The new "terminal UI isn't installed, run the installer" line only looks for gaia-tui on PATH. Someone who already ran the installer but only has the venv on PATH would be told to install it again. Also check GAIA's own bin folder.
  • The two fresh-install items in the test plan (Linux and Windows) are still unchecked. Those are the runs that prove this fix.

Real-world evidence

N/A: this run produced no evidence bundle. The verdict rests on static review alone. The PR description reports a manual check against a real uv venv (bare python -m pip and uv pip install fail, the --python form installs). Fresh install.sh / install.ps1 runs of gaia init are still open in its test plan. I couldn't run the unit tests here (pytest isn't installed in this runner), so they rest on CI.

🔍 Technical details

Issues

🟢 Install subprocess lost its timeout (src/gaia/installer/init_command.py, the subprocess.run in _install_pip_extras). The old code had timeout=300. It handled the timeout badly (warned, then returned True), but taking the timeout out entirely swaps a silent success for a possible silent hang. Add it back and make it fail loudly:

        try:
            result = subprocess.run(  # noqa: S603 - argv is constructed, not shell
                argv, capture_output=True, text=True, check=False, timeout=900
            )
        except subprocess.TimeoutExpired:
            self._print_error(
                f"Installing [{extras_str}] extras timed out. "
                f"Run `{retry}` yourself, then re-run `gaia init`."
            )
            return False
        except OSError as e:

🟢 has_tui only checks PATH (init_command.py, _print_completion). install.sh installs gaia-tui to $GAIA_HOME/bin (installer/scripts/install.sh:443), and the NSIS installer puts it in $INSTDIR. If that directory isn't on the current PATH, the completion screen tells a user who already ran the installer to run it again. Consider also checking ~/.gaia/bin/gaia-tui[.exe] before choosing which message to show.

🟢 format_command quoting edge cases (src/gaia/agents/install_hints.py). Double quotes don't stop $ or ` from expanding in bash, so putting them in _NEEDS_QUOTES gives a false sense of safety. Also, when display[0] is a quoted path (uv off PATH, under a path with spaces), PowerShell needs & "…" to run it. Both are rare enough to leave, but the comment's "every common shell" claim is broader than what the function guarantees.

Notes (no action needed)

  • _default_run_pip in hub/installer.py still leads with bare uv pip. That is fine as long as hub installs keep passing --target, because they then don't depend on an active venv.
  • A corrupt direct_url.json makes editable_gaia_root raise RuntimeError, which reaches run()'s top-level handler and the UI launcher uncaught. That is the right fail-loud behaviour.

Strengths

  • One shared function chooses the installer, and init, the UI hint and the chat-agent hint all use it, so the command init runs and the command the user is told to paste can't drift apart.
  • Reading PEP 610 direct_url.json to detect an editable install removes the old pip show probe, which needed a pip frontend that doesn't exist in this environment.
  • Tests assert the exact argv (the --python pin, one attempt with no fallback chain) and that a failed install makes run() return 1 before verification and the completion screen. That is the regression that matters.

Kalin Ovtcharov and others added 3 commits October 4, 2026 02:41
…n GAIA's bin dir

A hung download now fails gaia init after 15 minutes with the retry command
instead of hanging silently. The completion screen no longer tells someone who
already ran the installer to run it again when gaia-tui is in GAIA's bin dir
but not on PATH. Registers the reviewed S603 suppression for the extras
install and narrows the format_command quoting claim.
The NSIS installer puts gaia-tui.exe in its own InstallDir (default
%LOCALAPPDATA%\Programs\GAIA, recorded under HKCU\Software\AMD\GAIA), not
GAIA's bin dir. gaia init now checks there too, so a Windows user whose PATH
hasn't picked it up yet isn't told to run the installer again.
# Conflicts:
#	src/gaia/cli.py
#	src/gaia/installer/init_command.py
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 4, 2026
Merged via the queue into amd:main with commit 5c9381e Oct 4, 2026
@kovtcharov-amd
kovtcharov-amd deleted the kalin/installer-venv-pip branch October 4, 2026 17:22
aksh8b pushed a commit to aksh8b/gaia that referenced this pull request Oct 5, 2026
`gaia init` printed "failed models may be corrupted, here's how to
delete them" and then exited 0 with the completion banner, so scripted
installs and CI counted a setup whose model can't answer as done. Now a
model that fails its inference test ends init with exit 1 and an error
naming the model, under the same fix steps. Two softer cases stay
non-fatal, because setup still works, but are no longer quiet: a model
whose context size Lemonade doesn't report gets a warning with the fix,
and a failed Windows Installer process check is announced (msiexec still
fails loudly with 1618 on a real conflict).

Overlap: amd#4617 and amd#4520 also edit `init_command.py`, but in different
hunks. This branch merges cleanly with both, so merge order doesn't
matter.

## Test plan
- [x] `pytest
tests/unit/installer/test_init_verify_fails_on_bad_models.py`: init
exits 1 with the fix steps on a failed model and exits 0 when all pass;
the unverified-ctx warning and log entry; the announced msiexec-check
failure. 4 of the 5 tests fail on `main`.
- [x] `pytest tests/unit/test_init_command.py tests/unit/installer
tests/unit/chat/ui tests/unit/test_context_size_resolution.py` (1459
passed), run with fresh `GAIA_HOME` / `GAIA_DAEMON_HOME`
- [ ] On a machine with a deliberately truncated model file, `gaia init
--profile <p> --yes` exits non-zero and prints the delete/re-download
steps

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
aksh8b added a commit to aksh8b/gaia that referenced this pull request Oct 5, 2026
- source_install_command now builds on pip_install_hint (resolve_pip_frontend)
- Version pin + --force-reinstall --no-deps re-threaded through that shape
- agent_import_error_message/agent_wheel_failed_message kept; callsites updated
- Test in SourceInstallCommand adapted to pip_install_hint fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents cli CLI changes documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants