Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(upgrade): find uv outside shell path

cyhac2dc8fe1445
diff --git a/tests/e2e/test_upgrade_command.py b/tests/e2e/test_upgrade_command.py
index ce7ff0201..cf31da56d 100644
--- a/tests/e2e/test_upgrade_command.py
+++ b/tests/e2e/test_upgrade_command.py
@@ -66,8 +66,10 @@ def test_upgrade_command_uses_built_release_artifact():
[
"apt-get update >/dev/null",
"apt-get install -y --no-install-recommends curl ca-certificates bash procps >/dev/null",
- "curl -LsSf https://astral.sh/uv/install.sh | env UV_UNMANAGED_INSTALL=/usr/local/bin sh",
+ "curl -LsSf https://astral.sh/uv/install.sh | sh",
+ 'export PATH="$HOME/.local/bin:$PATH"',
f"UV_TOOL_BIN_DIR=/usr/local/bin uv tool install /fixtures/{initial_wheel_path.name} --force",
+ 'export PATH="/usr/local/bin:/usr/bin:/bin"',
"vibe version",
"VIBE_UPDATE_METADATA_URL=file:///fixtures/metadata.json "
f"VIBE_UPGRADE_PACKAGE_SPEC=/fixtures/{wheel_path.name} vibe check-update",
diff --git a/tests/test_upgrade_flow.py b/tests/test_upgrade_flow.py
index 58cc47434..9cd1eb6fe 100644
--- a/tests/test_upgrade_flow.py
+++ b/tests/test_upgrade_flow.py
@@ -50,6 +50,8 @@ def test_build_upgrade_plan_uses_pip_for_non_uv_install():
def test_build_upgrade_plan_uses_env_package_spec(monkeypatch):
monkeypatch.setenv("VIBE_UPGRADE_PACKAGE_SPEC", "/tmp/vibe_remote-9999.0.0-py3-none-any.whl")
+ monkeypatch.setattr("vibe.upgrade.os.path.exists", lambda path: True)
+ monkeypatch.setattr("vibe.upgrade.os.access", lambda path, mode: True)
plan = build_upgrade_plan(
python_executable="/tmp/.local/share/uv/tools/vibe-remote/bin/python",
@@ -68,6 +70,30 @@ def test_build_upgrade_plan_uses_env_package_spec(monkeypatch):
]
+def test_build_upgrade_plan_finds_uv_outside_current_path(monkeypatch):
+ monkeypatch.setattr(
+ "vibe.upgrade.shutil.which",
+ lambda command, path=None: None if command == "uv" else "/custom/bin/vibe",
+ )
+ monkeypatch.setattr(
+ "vibe.upgrade.os.path.exists",
+ lambda path: path in {"/home/test/.local/bin/uv", "/custom/bin/vibe"},
+ )
+ monkeypatch.setattr(
+ "vibe.upgrade.os.access",
+ lambda path, mode: path in {"/home/test/.local/bin/uv", "/custom/bin/vibe"},
+ )
+
+ plan = build_upgrade_plan(
+ python_executable="/tmp/.local/share/uv/tools/vibe-remote/bin/python",
+ vibe_path="/custom/bin/vibe",
+ base_env={"PATH": "/usr/local/bin:/usr/bin:/bin", "HOME": "/home/test"},
+ )
+
+ assert plan.method == "uv"
+ assert plan.command == ["/home/test/.local/bin/uv", "tool", "install", "vibe-remote", "--upgrade"]
+
+
def test_get_latest_version_info_uses_override_metadata_url(monkeypatch, tmp_path):
metadata_path = tmp_path / "metadata.json"
metadata_path.write_text('{"info": {"version": "9999.0.0"}}', encoding="utf-8")
diff --git a/vibe/upgrade.py b/vibe/upgrade.py
index 90361e2fe..8f28d5ff9 100644
--- a/vibe/upgrade.py
+++ b/vibe/upgrade.py
@@ -6,6 +6,7 @@ import shlex
import shutil
import sys
import urllib.request
+from collections.abc import Mapping
from dataclasses import dataclass
from pathlib import Path
@@ -13,6 +14,7 @@ from pathlib import Path
PACKAGE_NAME = "vibe-remote"
DEFAULT_UPDATE_METADATA_URL = f"https://pypi.org/pypi/{PACKAGE_NAME}/json"
CURRENT_VIBE_EXECUTABLE_ENV = "VIBE_CURRENT_EXECUTABLE"
+UV_FALLBACK_BIN_DIRS = (".local/bin", ".cargo/bin")
@dataclass(frozen=True)
@@ -45,6 +47,34 @@ def is_usable_command_path(path: str | None) -> bool:
return os.path.exists(path) and os.access(path, os.X_OK)
+def get_known_uv_paths(base_env: Mapping[str, str] | None = None) -> list[str]:
+ env = base_env or os.environ
+ home = env.get("HOME")
+ if home is not None:
+ return [os.path.join(home, bin_dir, "uv") for bin_dir in UV_FALLBACK_BIN_DIRS]
+ return [os.path.expanduser(f"~/{bin_dir}/uv") for bin_dir in UV_FALLBACK_BIN_DIRS]
+
+
+def find_uv_binary(uv_path: str | None = None, base_env: Mapping[str, str] | None = None) -> str | None:
+ env = base_env or os.environ
+ search_path = env.get("PATH")
+
+ resolved = resolve_command_path(uv_path, search_path=search_path)
+ if is_usable_command_path(resolved):
+ return resolved
+
+ resolved = resolve_command_path("uv", search_path=search_path)
+ if is_usable_command_path(resolved):
+ return resolved
+
+ for candidate in get_known_uv_paths(base_env=env):
+ resolved = resolve_command_path(candidate, search_path=search_path)
+ if is_usable_command_path(resolved):
+ return resolved
+
+ return None
+
+
def get_running_vibe_path(
*,
vibe_path: str | None = None,
@@ -60,8 +90,10 @@ def get_running_vibe_path(
return env_path
argv_path = resolve_command_path(argv0 or sys.argv[0], search_path=search_path)
- if is_usable_command_path(argv_path) and Path(argv_path).name.startswith("vibe"):
- return argv_path
+ if is_usable_command_path(argv_path):
+ argv_path_str = argv_path
+ if Path(argv_path_str).name.startswith("vibe"):
+ return argv_path_str
fallback_path = resolve_command_path("vibe", search_path=search_path)
if is_usable_command_path(fallback_path):
@@ -159,7 +191,7 @@ def build_upgrade_plan(
base_env: dict[str, str] | None = None,
) -> UpgradePlan:
executable = python_executable or sys.executable
- uv_binary = uv_path if uv_path is not None else shutil.which("uv")
+ uv_binary = find_uv_binary(uv_path=uv_path, base_env=base_env)
package_spec = get_upgrade_package_spec()
if is_uv_tool_install(executable) and uv_binary: