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): preserve uv launcher bins

cyh8302fd51c066
diff --git a/install.sh b/install.sh
index ad37941e5..ee6a4da5b 100755
--- a/install.sh
+++ b/install.sh
@@ -104,7 +104,7 @@ is_transient_bin_dir() {
local dir="$1"
case "$dir" in
- */.venv/bin|*/venv/bin|*/env/bin|*/.pyenv/versions/*/bin|*/.local/share/mise/installs/*/bin|*/.mise/installs/*/bin)
+ */.venv/bin|*/venv/bin|*/env/bin|*/.pyenv/shims|*/.pyenv/versions/*/bin|*/.local/share/mise/installs/*/bin|*/.mise/installs/*/bin)
return 0
;;
esac
@@ -119,6 +119,7 @@ is_transient_bin_dir() {
if [ -n "${PYENV_ROOT:-}" ]; then
case "$dir" in
+ "${PYENV_ROOT%/}"/shims) return 0 ;;
"${PYENV_ROOT%/}"/versions/*/bin) return 0 ;;
esac
fi
diff --git a/tests/e2e/test_upgrade_command.py b/tests/e2e/test_upgrade_command.py
index cf31da56d..7a69c677b 100644
--- a/tests/e2e/test_upgrade_command.py
+++ b/tests/e2e/test_upgrade_command.py
@@ -68,7 +68,8 @@ def test_upgrade_command_uses_built_release_artifact():
"apt-get install -y --no-install-recommends curl ca-certificates bash procps >/dev/null",
"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",
+ f"uv tool install /fixtures/{initial_wheel_path.name} --force",
+ 'ln -sf "$HOME/.local/bin/vibe" /usr/local/bin/vibe',
'export PATH="/usr/local/bin:/usr/bin:/bin"',
"vibe version",
"VIBE_UPDATE_METADATA_URL=file:///fixtures/metadata.json "
diff --git a/tests/test_install_script.py b/tests/test_install_script.py
index 4765594e9..873befadc 100644
--- a/tests/test_install_script.py
+++ b/tests/test_install_script.py
@@ -215,6 +215,30 @@ def test_install_script_skips_pyenv_and_mise_bin_dirs(tmp_path):
assert not (mise_bin / "vibe").exists()
+def test_install_script_skips_pyenv_shims_dir(tmp_path):
+ home_dir = tmp_path / "home"
+ home_dir.mkdir()
+ pyenv_root = tmp_path / ".pyenv"
+ shims_dir = pyenv_root / "shims"
+ shims_dir.mkdir(parents=True)
+ stable_bin = tmp_path / "stable-bin"
+ stable_bin.mkdir()
+ uv_log = tmp_path / "uv-tool-bin-dir.txt"
+
+ _write_fake_uv(stable_bin / "uv", uv_log)
+
+ env = os.environ.copy()
+ env["HOME"] = str(home_dir)
+ env["PATH"] = os.pathsep.join([str(shims_dir), str(stable_bin), "/usr/bin", "/bin"])
+ env["PYENV_ROOT"] = str(pyenv_root)
+
+ install_result = _install(env, cwd=tmp_path)
+
+ assert install_result.returncode == 0, install_result.stdout + install_result.stderr
+ assert uv_log.read_text(encoding="utf-8") == str(stable_bin)
+ assert not (shims_dir / "vibe").exists()
+
+
def test_install_script_prefers_bin_over_sbin(tmp_path):
home_dir = tmp_path / "home"
home_dir.mkdir()
diff --git a/tests/test_upgrade_flow.py b/tests/test_upgrade_flow.py
index 9cd1eb6fe..07f8810d7 100644
--- a/tests/test_upgrade_flow.py
+++ b/tests/test_upgrade_flow.py
@@ -11,6 +11,7 @@ from vibe import api, cli
from vibe.upgrade import (
UpgradePlan,
build_upgrade_plan,
+ get_current_vibe_bin_dir,
get_latest_version_info,
get_restart_command,
get_running_vibe_path,
@@ -94,6 +95,26 @@ def test_build_upgrade_plan_finds_uv_outside_current_path(monkeypatch):
assert plan.command == ["/home/test/.local/bin/uv", "tool", "install", "vibe-remote", "--upgrade"]
+def test_get_current_vibe_bin_dir_resolves_launcher_target(monkeypatch):
+ monkeypatch.setattr("vibe.upgrade.os.path.exists", lambda path: True)
+ monkeypatch.setattr("vibe.upgrade.os.access", lambda path, mode: True)
+ monkeypatch.setattr(
+ "vibe.upgrade.os.path.islink",
+ lambda path: path in {"/usr/local/bin/vibe", "/home/test/.local/bin/vibe"},
+ )
+ monkeypatch.setattr(
+ "vibe.upgrade.os.readlink",
+ lambda path: {
+ "/usr/local/bin/vibe": "/home/test/.local/bin/vibe",
+ "/home/test/.local/bin/vibe": "/home/test/.local/share/uv/tools/vibe-remote/bin/vibe",
+ }[path],
+ )
+
+ bin_dir = get_current_vibe_bin_dir(vibe_path="/usr/local/bin/vibe")
+
+ assert bin_dir == "/home/test/.local/bin"
+
+
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 8f28d5ff9..11519d859 100644
--- a/vibe/upgrade.py
+++ b/vibe/upgrade.py
@@ -9,6 +9,7 @@ import urllib.request
from collections.abc import Mapping
from dataclasses import dataclass
from pathlib import Path
+from typing import cast
PACKAGE_NAME = "vibe-remote"
@@ -47,6 +48,24 @@ def is_usable_command_path(path: str | None) -> bool:
return os.path.exists(path) and os.access(path, os.X_OK)
+def get_launcher_bin_dir(command_path: str) -> str:
+ current = os.path.abspath(os.path.expanduser(command_path))
+
+ while os.path.islink(current):
+ target = os.readlink(current)
+ if not os.path.isabs(target):
+ target = os.path.abspath(os.path.join(os.path.dirname(current), target))
+ else:
+ target = os.path.abspath(os.path.expanduser(target))
+
+ if not os.path.islink(target):
+ return str(Path(current).parent)
+
+ current = target
+
+ return str(Path(current).parent)
+
+
def get_known_uv_paths(base_env: Mapping[str, str] | None = None) -> list[str]:
env = base_env or os.environ
home = env.get("HOME")
@@ -91,7 +110,7 @@ def get_running_vibe_path(
argv_path = resolve_command_path(argv0 or sys.argv[0], search_path=search_path)
if is_usable_command_path(argv_path):
- argv_path_str = argv_path
+ argv_path_str = cast(str, argv_path)
if Path(argv_path_str).name.startswith("vibe"):
return argv_path_str
@@ -180,7 +199,8 @@ def get_current_vibe_bin_dir(vibe_path: str | None = None) -> str | None:
current_vibe = get_running_vibe_path(vibe_path=vibe_path)
if not current_vibe:
return None
- return str(Path(current_vibe).expanduser().parent)
+
+ return get_launcher_bin_dir(current_vibe)
def build_upgrade_plan(