Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(setup): recover in-app installs when the environment has no pip module (BUG-073)

Ruben Lütke5c33c0653cd6
diff --git a/docs/BUGS.md b/docs/BUGS.md
index 53f437eb98..83410aed25 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -5256,3 +5256,47 @@ calls). Cap reasoning at the REQUEST level (config-level caps drift onto
the wrong provider entry), key caches on every legitimately-varying axis,
and never feed a model a serialized imitation of its own native call
format — it will copy it.
+
+## BUG-073: In-app local-speech install always fails with "No module named pip" — uv-created venvs ship without pip (HIGH, FIXED 2026-07-17)
+
+**Symptom (maintainer report 2026-07-17).** Enabling the local speech pack
+from the wake-word settings fails every time with
+`pip exited 1: <venv>/Scripts/pythonw.exe: No module named pip`, on the
+maintainer's Windows box AND on the real-Mac test run. The UI's generic
+hint ("usually no prebuilt package for this Python/system") pointed at the
+wrong cause.
+
+**Root cause.** `install_pip_package` runs `sys.executable -m pip install`
+unconditionally — but environments created by `uv venv` deliberately omit
+the pip module (uv installs from outside the env), so the invocation dies
+before it can install anything. Both affected machines run uv-created
+venvs (`pyvenv.cfg`: `uv = 0.11.19`). The official `install.ps1/.sh` path
+uses `python -m venv` (pip included), which is why the wizard never hit it;
+any uv-based setup — increasingly the ecosystem default — was structurally
+broken for every in-app install, violating the §3 "recoverable in-app"
+contract.
+
+**Fix (jarvis/setup/dependencies.py).** The pip attempt stays the primary
+path (environments with pip pay zero extra subprocess calls). On the exact
+`No module named pip` failure a recovery chain runs: (1)
+`<python> -m ensurepip --upgrade` — the stdlib bootstrap installs pip INTO
+the environment, a permanent repair — then the pip install is retried;
+(2) if ensurepip cannot help, `uv pip install --python <sys.executable>`
+with the on-PATH uv binary (near-certain to exist given a uv-created
+venv), propagating `--only-binary`; (3) otherwise an actionable failure
+message naming the manual `ensurepip` command. `classify_pip_failure`
+additionally learned uv's empirically-captured wordings for the no-wheel
+("No solution found when resolving", "has no usable wheels") and network
+("Failed to fetch", "error sending request") diagnoses so the BUG-059
+honest-diagnosis contract holds on the uv path too.
+
+**Guards.** `tests/unit/setup/test_install_without_pip.py` (bootstrap
+chain, uv fallback + flag propagation, actionable no-recovery message,
+single-subprocess happy path, uv wording classification).
+
+**Lesson.** "python -m pip" is NOT a universal invariant of a Python
+environment — uv-created venvs (and stripped system Pythons) don't have
+it. Any runtime code that shells out to pip must treat "No module named
+pip" as a repairable state (ensurepip / uv fallback), not a terminal
+error, or every in-app install silently bricks for the growing uv-managed
+install base.
diff --git a/jarvis/setup/dependencies.py b/jarvis/setup/dependencies.py
index e139120109..c1e7bf4c0c 100644
--- a/jarvis/setup/dependencies.py
+++ b/jarvis/setup/dependencies.py
@@ -246,6 +246,9 @@ def install_npm_package(package: str, *, timeout_s: float = 300.0) -> tuple[bool
# Marker substrings for classify_pip_failure, matched case-insensitively.
# Network first would be wrong: a source-build log can mention retries, so the
# more specific build/no-wheel signatures win before network generalities.
+# Covers BOTH pip and uv wordings — the no-pip fallback path (BUG-073) may
+# install via ``uv pip install``, whose resolver phrases the same failures
+# differently (captured empirically from uv 0.11).
_PIP_NO_WHEEL_MARKERS = (
"failed to build",
"getting requirements to build wheel",
@@ -254,6 +257,10 @@ _PIP_NO_WHEEL_MARKERS = (
"could not find a version that satisfies",
"microsoft visual c++",
"fatal error:",
+ # uv resolver wordings
+ "no solution found when resolving",
+ "has no usable wheels",
+ "building from source is disabled",
)
_PIP_NETWORK_MARKERS = (
"newconnectionerror",
@@ -263,17 +270,22 @@ _PIP_NETWORK_MARKERS = (
"network is unreachable",
"proxyerror",
"ssl: certificate",
+ # uv network wordings
+ "failed to fetch",
+ "error sending request",
+ "request failed after",
)
def classify_pip_failure(stderr: str) -> str | None:
- """Turn pip's stderr tail into an honest one-line diagnosis, or ``None``.
+ """Turn the installer's stderr tail into an honest one-line diagnosis.
BUG-059: on the first real-Mac onboarding a missing cp314/macOS wheel for
``av`` sent pip into an FFmpeg SOURCE build that no end user can satisfy —
and the UI blamed the internet connection. A missing prebuilt wheel (or
the source build it triggers) must be named as such; only genuine network
- signatures may point at the network.
+ signatures may point at the network. Returns ``None`` when neither
+ signature class matches.
"""
s = (stderr or "").lower()
if any(marker in s for marker in _PIP_NO_WHEEL_MARKERS):
@@ -292,29 +304,16 @@ def classify_pip_failure(stderr: str) -> str | None:
return None
-def install_pip_package(
- package: str, *, timeout_s: float = 600.0, only_binary: bool = False
-) -> tuple[bool, str]:
- """Best-effort ``<python> -m pip install <package>`` into the RUNNING
- interpreter. Never raises. Returns ``(ok, message)``.
+_ENSUREPIP_TIMEOUT_S: Final[float] = 180.0
- Used to pull an opt-in runtime extra from inside the app (e.g.
- ``faster-whisper`` for the any-phrase local wake path), so a user never has
- to drop to a shell — the CLAUDE.md §3 "recoverable in-app" contract. Runs
- against ``sys.executable`` so the package lands in the same environment the
- app imports from, and passes ``NO_WINDOW_CREATIONFLAGS`` so a ``pythonw.exe``
- host does not flash a console (AP-1). Cross-platform: ``python -m pip`` is
- the one install invocation that behaves identically on Windows/macOS/Linux.
- A frozen/no-pip interpreter fails cleanly with a message instead of raising.
+# The exact failure a pip-less interpreter prints for ``<python> -m pip``;
+# uv-created venvs omit pip by design, so this is a repairable state, not a
+# terminal one (BUG-073).
+_NO_PIP_MARKER: Final[str] = "no module named pip"
- ``only_binary=True`` adds ``--only-binary=:all:`` — for end-user-facing
- installs of native packages, so pip fails fast with the honest no-wheel
- diagnosis instead of attempting a source build (FFmpeg/toolchain) that no
- end user can satisfy (BUG-059).
- """
- if not sys.executable:
- return False, "no Python interpreter available to run pip"
+def _pip_install_cmd(package: str, *, only_binary: bool) -> list[str]:
+ """Build the ``<python> -m pip install`` argv for ``package``."""
cmd = [
sys.executable, "-m", "pip", "install",
"--disable-pip-version-check",
@@ -322,7 +321,17 @@ def install_pip_package(
if only_binary:
cmd += ["--only-binary", ":all:"]
cmd.append(package)
+ return cmd
+
+def _run_installer(
+ cmd: list[str], *, timeout_s: float, flavor: str
+) -> tuple[bool, str]:
+ """Run one install command. Never raises. Returns ``(ok, message)``.
+
+ ``flavor`` names the tool ("pip" / "uv") in failure messages so the UI
+ detail is honest about which installer actually ran.
+ """
logger.info("install_pip_package: %s", " ".join(cmd))
try:
result = subprocess.run( # noqa: S603 -- args are controlled, not user input
@@ -333,21 +342,114 @@ def install_pip_package(
creationflags=NO_WINDOW_CREATIONFLAGS,
)
except subprocess.TimeoutExpired:
- return False, f"pip install timed out after {timeout_s:.0f}s"
+ return False, f"{flavor} install timed out after {timeout_s:.0f}s"
except OSError as exc:
- return False, f"pip spawn failed: {exc}"
+ return False, f"{flavor} spawn failed: {exc}"
if result.returncode != 0:
- # The tail of stderr carries pip's actual reason (resolver conflict,
- # no matching wheel for the platform, network error).
+ # The tail of stderr carries the installer's actual reason (resolver
+ # conflict, no matching wheel for the platform, network error).
stderr = (result.stderr or "").strip()[-600:]
- raw = f"pip exited {result.returncode}: {stderr or 'no stderr'}"
+ raw = f"{flavor} exited {result.returncode}: {stderr or 'no stderr'}"
diagnosis = classify_pip_failure(stderr)
return False, f"{diagnosis} [{raw}]" if diagnosis else raw
return True, (result.stdout or "").strip()[-400:] or "install reported success"
+def _install_without_pip(
+ package: str, *, timeout_s: float, only_binary: bool, pip_error: str
+) -> tuple[bool, str]:
+ """Recover an in-app install when the environment has NO pip module.
+
+ BUG-073: environments created by ``uv venv`` ship without pip by design,
+ so ``<python> -m pip`` dies with "No module named pip" before it can
+ install anything — hit on both the maintainer's Windows box and the
+ first real-Mac test run. Recovery order:
+
+ 1. ``<python> -m ensurepip --upgrade`` (stdlib) installs pip INTO the
+ environment — a permanent repair — then the pip install is retried.
+ 2. When ensurepip cannot help (some system Pythons strip it), fall back
+ to ``uv pip install --python <python>`` with the uv binary on PATH —
+ near-certain to exist given a uv-created venv.
+ 3. Otherwise fail with an actionable message naming both escapes.
+ """
+ logger.info("pip module missing; bootstrapping via ensurepip")
+ try:
+ bootstrap = subprocess.run( # noqa: S603 -- args are controlled
+ [sys.executable, "-m", "ensurepip", "--upgrade"],
+ capture_output=True,
+ text=True,
+ timeout=_ENSUREPIP_TIMEOUT_S,
+ creationflags=NO_WINDOW_CREATIONFLAGS,
+ )
+ bootstrapped = bootstrap.returncode == 0
+ except (subprocess.TimeoutExpired, OSError) as exc:
+ logger.debug("ensurepip bootstrap failed: %s", exc)
+ bootstrapped = False
+
+ if bootstrapped:
+ ok, message = _run_installer(
+ _pip_install_cmd(package, only_binary=only_binary),
+ timeout_s=timeout_s,
+ flavor="pip",
+ )
+ if ok or _NO_PIP_MARKER not in message.lower():
+ return ok, message
+
+ uv_path = _resolve_binary("uv")
+ if uv_path is not None:
+ cmd = [uv_path, "pip", "install", "--python", sys.executable]
+ if only_binary:
+ cmd += ["--only-binary", ":all:"]
+ cmd.append(package)
+ return _run_installer(cmd, timeout_s=timeout_s, flavor="uv")
+
+ return False, (
+ "This Python environment was created without pip (uv does this by "
+ "design) and could not be repaired automatically: ensurepip is "
+ "unavailable and no uv binary is on PATH. Run "
+ f'`"{sys.executable}" -m ensurepip --upgrade` once, then retry. '
+ f"[{pip_error}]"
+ )
+
+
+def install_pip_package(
+ package: str, *, timeout_s: float = 600.0, only_binary: bool = False
+) -> tuple[bool, str]:
+ """Best-effort install of ``package`` into the RUNNING interpreter's
+ environment. Never raises. Returns ``(ok, message)``.
+
+ Used to pull an opt-in runtime extra from inside the app (e.g.
+ ``faster-whisper`` for the any-phrase local wake path), so a user never has
+ to drop to a shell — the CLAUDE.md §3 "recoverable in-app" contract. Runs
+ against ``sys.executable`` so the package lands in the same environment the
+ app imports from, and passes ``NO_WINDOW_CREATIONFLAGS`` so a ``pythonw.exe``
+ host does not flash a console (AP-1). Cross-platform: ``python -m pip`` is
+ the primary invocation on Windows/macOS/Linux; an environment with no pip
+ module at all (uv-created venvs omit it — BUG-073) is repaired via
+ ensurepip or served through ``uv pip install`` instead of failing.
+
+ ``only_binary=True`` adds ``--only-binary=:all:`` — for end-user-facing
+ installs of native packages, so the installer fails fast with the honest
+ no-wheel diagnosis instead of attempting a source build (FFmpeg/toolchain)
+ that no end user can satisfy (BUG-059).
+ """
+ if not sys.executable:
+ return False, "no Python interpreter available to run pip"
+
+ ok, message = _run_installer(
+ _pip_install_cmd(package, only_binary=only_binary),
+ timeout_s=timeout_s,
+ flavor="pip",
+ )
+ if ok or _NO_PIP_MARKER not in message.lower():
+ return ok, message
+ return _install_without_pip(
+ package, timeout_s=timeout_s, only_binary=only_binary, pip_error=message
+ )
+
+
def install_claude_cli() -> tuple[bool, DependencyStatus]:
"""Auto-install + re-probe ``claude``. Returns the post-install status."""
ok, message = install_npm_package("@anthropic-ai/claude-code")
diff --git a/tests/unit/setup/test_install_without_pip.py b/tests/unit/setup/test_install_without_pip.py
new file mode 100644
index 0000000000..fab4479a23
--- /dev/null
+++ b/tests/unit/setup/test_install_without_pip.py
@@ -0,0 +1,161 @@
+"""In-app installs recover when the environment has no pip module (BUG-073).
+
+``uv venv`` creates environments WITHOUT pip by design, so the local-speech
+install died with ``pythonw.exe: No module named pip`` on the maintainer's
+Windows box and again on the real-Mac test run. Contracts locked here:
+
+1. A "No module named pip" failure bootstraps pip via ``ensurepip`` and
+ retries — a permanent repair of the environment.
+2. When ensurepip cannot help, the install falls back to
+ ``uv pip install --python <sys.executable>`` with a uv binary on PATH,
+ propagating ``--only-binary``.
+3. When neither escape exists, the message names the manual fix and keeps
+ the raw cause.
+4. Environments WITH pip never pay for the recovery: the happy path stays
+ a single subprocess call.
+5. ``classify_pip_failure`` understands uv's wordings for the no-wheel and
+ network cases (captured empirically from uv 0.11).
+"""
+from __future__ import annotations
+
+import sys
+from types import SimpleNamespace
+
+from jarvis.setup import dependencies as deps
+
+_NO_PIP_STDERR = "/opt/jarvis/.venv/bin/python: No module named pip"
+
+
+def _scripted_run(outcomes: list[tuple[int, str, str]], calls: list[list[str]]):
+ """Fake subprocess.run returning the scripted outcomes in call order."""
+ queue = iter(outcomes)
+
+ def _run(cmd, **_kw):
+ calls.append(list(cmd))
+ rc, out, err = next(queue)
+ return SimpleNamespace(returncode=rc, stdout=out, stderr=err)
+
+ return _run
+
+
+def test_no_pip_bootstraps_ensurepip_then_retries(monkeypatch) -> None:
+ calls: list[list[str]] = []
+ monkeypatch.setattr(
+ deps.subprocess,
+ "run",
+ _scripted_run(
+ [
+ (1, "", _NO_PIP_STDERR), # pip install: env has no pip module
+ (0, "", ""), # ensurepip --upgrade repairs it
+ (0, "ok", ""), # pip install retry succeeds
+ ],
+ calls,
+ ),
+ )
+ ok, msg = deps.install_pip_package("faster-whisper>=1.0", only_binary=True)
+ assert ok is True
+ assert [c[1:3] for c in calls] == [
+ ["-m", "pip"],
+ ["-m", "ensurepip"],
+ ["-m", "pip"],
+ ]
+ assert "--upgrade" in calls[1]
+
+
+def test_no_pip_falls_back_to_uv_when_ensurepip_cannot_help(monkeypatch) -> None:
+ calls: list[list[str]] = []
+ monkeypatch.setattr(
+ deps.subprocess,
+ "run",
+ _scripted_run(
+ [
+ (1, "", _NO_PIP_STDERR), # pip install: no pip module
+ (1, "", "no module named ensurepip"), # stripped system Python
+ (0, "", "Installed 1 package"), # uv pip install succeeds
+ ],
+ calls,
+ ),
+ )
+ monkeypatch.setattr(
+ deps, "_resolve_binary", lambda name: "/fake/uv" if name == "uv" else None
+ )
+ ok, _ = deps.install_pip_package("faster-whisper>=1.0", only_binary=True)
+ assert ok is True
+ uv_cmd = calls[2]
+ assert uv_cmd[:3] == ["/fake/uv", "pip", "install"]
+ assert "--python" in uv_cmd
+ assert sys.executable in uv_cmd
+ assert "--only-binary" in uv_cmd
+ assert ":all:" in uv_cmd
+
+
+def test_no_pip_and_no_recovery_names_the_manual_fix(monkeypatch) -> None:
+ calls: list[list[str]] = []
+ monkeypatch.setattr(
+ deps.subprocess,
+ "run",
+ _scripted_run(
+ [
+ (1, "", _NO_PIP_STDERR),
+ (1, "", "no module named ensurepip"),
+ ],
+ calls,
+ ),
+ )
+ monkeypatch.setattr(deps, "_resolve_binary", lambda name: None)
+ ok, msg = deps.install_pip_package("rich")
+ assert ok is False
+ assert "ensurepip" in msg
+ assert "no module named pip" in msg.lower() # raw cause preserved
+
+
+def test_env_with_pip_stays_single_subprocess(monkeypatch) -> None:
+ calls: list[list[str]] = []
+ monkeypatch.setattr(
+ deps.subprocess, "run", _scripted_run([(0, "ok", "")], calls)
+ )
+ ok, _ = deps.install_pip_package("rich")
+ assert ok is True
+ assert len(calls) == 1
+
+
+def test_uv_failure_message_names_uv_not_pip(monkeypatch) -> None:
+ calls: list[list[str]] = []
+ monkeypatch.setattr(
+ deps.subprocess,
+ "run",
+ _scripted_run(
+ [
+ (1, "", _NO_PIP_STDERR),
+ (1, "", "no module named ensurepip"),
+ (1, "", "some uv failure"),
+ ],
+ calls,
+ ),
+ )
+ monkeypatch.setattr(
+ deps, "_resolve_binary", lambda name: "/fake/uv" if name == "uv" else None
+ )
+ ok, msg = deps.install_pip_package("rich")
+ assert ok is False
+ assert "uv exited 1" in msg
+
+
+def test_uv_no_wheel_wording_gets_the_prebuilt_diagnosis() -> None:
+ msg = deps.classify_pip_failure(
+ "No solution found when resolving dependencies: Because av==10.0.0 "
+ "has no usable wheels and you require av==10.0.0, we can conclude "
+ "that your requirements are unsatisfiable."
+ )
+ assert msg is not None
+ assert "prebuilt" in msg.lower()
+
+
+def test_uv_network_wording_gets_the_network_diagnosis() -> None:
+ msg = deps.classify_pip_failure(
+ "error: Request failed after 3 retries\n"
+ "Caused by: Failed to fetch: `https://pypi.org/simple/cowsay/`\n"
+ "Caused by: error sending request for url"
+ )
+ assert msg is not None
+ assert "network" in msg.lower()