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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(upgrade): use safe cwd for uv subprocess to prevent stale venv directory errors
cyh4ab16988c4ba
diff --git a/tests/test_upgrade_flow.py b/tests/test_upgrade_flow.pyindex 07f8810d7..c1abec980 100644--- a/tests/test_upgrade_flow.py+++ b/tests/test_upgrade_flow.py@@ -1,5 +1,6 @@from __future__ import annotations+import osimport subprocessimport sysfrom pathlib import Path@@ -203,15 +204,17 @@ def test_do_upgrade_uses_upgrade_plan_env_and_restarts(monkeypatch):assert result["ok"] is Trueassert result["restarting"] is Trueassert calls["run_cmd"] == plan.command- assert calls["run_kwargs"] == {- "capture_output": True,- "text": True,- "timeout": 120,- "env": plan.env,- }+ assert calls["run_kwargs"]["capture_output"] is True+ assert calls["run_kwargs"]["text"] is True+ assert calls["run_kwargs"]["timeout"] == 120+ assert calls["run_kwargs"]["env"] == plan.env+ safe_cwd = calls["run_kwargs"].get("cwd")+ assert safe_cwd and os.path.isabs(safe_cwd), f"subprocess.run cwd must be an absolute path, got {safe_cwd!r}"assert calls["popen_cmd"] == "sleep 2 && /custom/bin/vibe"assert calls["popen_kwargs"]["shell"] is Trueassert calls["popen_kwargs"]["start_new_session"] is True+ popen_cwd = calls["popen_kwargs"].get("cwd")+ assert popen_cwd and os.path.isabs(popen_cwd), f"Popen cwd must be an absolute path, got {popen_cwd!r}"def test_cmd_upgrade_uses_upgrade_plan_env(monkeypatch):@@ -237,7 +240,11 @@ def test_cmd_upgrade_uses_upgrade_plan_env(monkeypatch):assert result == 0assert calls["cmd"] == plan.command- assert calls["kwargs"] == {"capture_output": True, "text": True, "env": plan.env}+ assert calls["kwargs"]["capture_output"] is True+ assert calls["kwargs"]["text"] is True+ assert calls["kwargs"]["env"] == plan.env+ assert "cwd" in calls["kwargs"], "subprocess.run must specify cwd to avoid stale venv cwd"+ assert os.path.isabs(calls["kwargs"]["cwd"]), f"cwd must be absolute, got {calls['kwargs']['cwd']!r}"def test_cmd_upgrade_skips_install_when_already_latest(monkeypatch):diff --git a/vibe/api.py b/vibe/api.pyindex e1f06e5d9..247215ffc 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -21,7 +21,11 @@ from config.v2_settings import (_routing_to_dict,)from config.v2_sessions import SessionsStore-from vibe.opencode_config import get_opencode_config_paths, load_first_opencode_user_config, set_jsonc_top_level_string_property+from vibe.opencode_config import (+ get_opencode_config_paths,+ load_first_opencode_user_config,+ set_jsonc_top_level_string_property,+)from vibe.upgrade import build_upgrade_plan, get_latest_version_info, get_restart_shell_command, get_running_vibe_path@@ -652,6 +656,11 @@ def do_upgrade(auto_restart: bool = True) -> dict:current_vibe_path = get_running_vibe_path()plan = build_upgrade_plan(vibe_path=current_vibe_path)+ # Use home directory as cwd to avoid "Current directory does not exist" errors.+ # The vibe service process cwd may be inside the uv tool venv directory, which+ # uv deletes and recreates during upgrade.+ safe_cwd = os.path.expanduser("~")+try:result = subprocess.run(plan.command,@@ -659,6 +668,7 @@ def do_upgrade(auto_restart: bool = True) -> dict:text=True,timeout=120,env=plan.env,+ cwd=safe_cwd,)if result.returncode == 0:restarting = False@@ -670,6 +680,7 @@ def do_upgrade(auto_restart: bool = True) -> dict:stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,start_new_session=True,+ cwd=safe_cwd,)restarting = True@@ -740,7 +751,9 @@ def setup_opencode_permission() -> dict:return {"ok": False, "message": str(e), "config_path": str(probe.path)}if probe.existing_paths:- error_path, error_message = probe.errors[0] if probe.errors else (probe.existing_paths[0], "unknown parse error")+ error_path, error_message = (+ probe.errors[0] if probe.errors else (probe.existing_paths[0], "unknown parse error")+ )logger.error(f"Refusing to overwrite invalid OpenCode config at {error_path}: {error_message}")return {"ok": False,diff --git a/vibe/cli.py b/vibe/cli.pyindex cde1d2c74..dc7a99c45 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -652,8 +652,12 @@ def cmd_upgrade():plan = build_upgrade_plan(vibe_path=current_vibe_path)print(f"Using {plan.method}: {' '.join(plan.command)}")+ # Use home directory as cwd to avoid issues when running from a directory+ # that uv may delete during upgrade (e.g. inside the uv tool venv).+ safe_cwd = os.path.expanduser("~")+try:- result = subprocess.run(plan.command, capture_output=True, text=True, env=plan.env)+ result = subprocess.run(plan.command, capture_output=True, text=True, env=plan.env, cwd=safe_cwd)if result.returncode == 0:print("\033[32mUpgrade successful!\033[0m")print("Please restart vibe to use the new version:")