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(dictation): find the worker interpreter when the branded exe stands alone

rubenluetke10-beep9d2d4ca520fe
diff --git a/jarvis/dictation/local_preview.py b/jarvis/dictation/local_preview.py
index 74ddc3e817..62982c4fe6 100644
--- a/jarvis/dictation/local_preview.py
+++ b/jarvis/dictation/local_preview.py
@@ -103,18 +103,28 @@ def faster_whisper_available() -> bool:
def _child_python() -> str:
"""The interpreter for the preview worker, beside the running executable.
- ``sys.executable`` in the desktop app is the venv's GUI entry point
- (``PersonalJarvis.exe``), which cannot take ``-m`` — the real
- ``python(.exe)`` lives in the same Scripts/bin directory.
+ ``sys.executable`` in the desktop app is the branded ``PersonalJarvis.exe``,
+ which cannot take ``-m``. Usually the real ``python(.exe)`` lives in the
+ same directory, but the per-user branded copy in
+ ``%LOCALAPPDATA%\\PersonalJarvis\\bin`` carries only the runtime DLLs — so
+ the active environment's own interpreter directory, then the base
+ install's, are searched next. Without that fallback every dictation after
+ a launch through that copy failed with "no local dictation worker".
"""
exe = Path(sys.executable)
if exe.stem.lower().startswith("python"):
return str(exe)
- for name in ("python.exe", "python"):
- candidate = exe.parent / name
- if candidate.exists():
- return str(candidate)
- raise RuntimeError(f"no python interpreter beside {exe}")
+ names = ("python.exe", "python") if sys.platform == "win32" else ("python3", "python")
+ dirs = [exe.parent]
+ for prefix in dict.fromkeys((sys.prefix, sys.base_prefix)):
+ root = Path(prefix)
+ dirs += [root / "Scripts", root] if sys.platform == "win32" else [root / "bin"]
+ for directory in dirs:
+ for name in names:
+ candidate = directory / name
+ if candidate.is_file():
+ return str(candidate)
+ raise RuntimeError(f"no python interpreter beside {exe} or in {sys.prefix}")
def _close_worker_process(proc: subprocess.Popen[bytes]) -> None:
diff --git a/tests/unit/dictation/test_local_preview.py b/tests/unit/dictation/test_local_preview.py
index fe50bd6a09..75390e6698 100644
--- a/tests/unit/dictation/test_local_preview.py
+++ b/tests/unit/dictation/test_local_preview.py
@@ -437,3 +437,46 @@ async def test_a_late_but_successful_preview_ends_the_failure_streak():
assert engine.ready is True
finally:
mod.PREVIEW_TIMEOUT_S = original
+
+
+def test_the_worker_interpreter_is_found_when_the_branded_exe_stands_alone(
+ monkeypatch, tmp_path
+):
+ """The per-user branded copy has no python beside it (2026-10-02).
+
+ ``%LOCALAPPDATA%/PersonalJarvis/bin`` holds only ``PersonalJarvis.exe`` and
+ the runtime DLLs; the interpreter lives in the environment's own directory.
+ """
+ import sys
+
+ from jarvis.dictation import local_preview
+
+ branded_dir = tmp_path / "bin"
+ branded_dir.mkdir()
+ branded = branded_dir / "PersonalJarvis.exe"
+ branded.write_bytes(b"")
+ env = tmp_path / "env"
+ interp_dir = env / "Scripts" if sys.platform == "win32" else env / "bin"
+ interp_dir.mkdir(parents=True)
+ interp = interp_dir / ("python.exe" if sys.platform == "win32" else "python3")
+ interp.write_bytes(b"")
+ monkeypatch.setattr(sys, "executable", str(branded))
+ monkeypatch.setattr(sys, "prefix", str(env))
+ monkeypatch.setattr(sys, "base_prefix", str(tmp_path / "missing"))
+
+ assert local_preview._child_python() == str(interp)
+
+
+def test_a_missing_worker_interpreter_still_fails_loudly(monkeypatch, tmp_path):
+ import sys
+
+ from jarvis.dictation import local_preview
+
+ branded = tmp_path / "PersonalJarvis.exe"
+ branded.write_bytes(b"")
+ monkeypatch.setattr(sys, "executable", str(branded))
+ monkeypatch.setattr(sys, "prefix", str(tmp_path / "nowhere"))
+ monkeypatch.setattr(sys, "base_prefix", str(tmp_path / "nowhere"))
+
+ with pytest.raises(RuntimeError, match="no python interpreter"):
+ local_preview._child_python()