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): add get_safe_cwd() with fallback and update README badges
cyhf9abdc10eff8
diff --git a/README.md b/README.mdindex f9d414586..e93d028aa 100644--- a/README.md+++ b/README.md@@ -16,7 +16,7 @@**Supported Platforms**-+@@ -24,8 +24,8 @@**Supported Agents**--++---diff --git a/README_ZH.md b/README_ZH.mdindex 22abb2d3f..b0defd83f 100644--- a/README_ZH.md+++ b/README_ZH.md@@ -16,7 +16,7 @@**支持的平台**-+@@ -24,8 +24,8 @@**支持的 Agent**--++---diff --git a/tests/test_upgrade_flow.py b/tests/test_upgrade_flow.pyindex c1abec980..1757854dc 100644--- a/tests/test_upgrade_flow.py+++ b/tests/test_upgrade_flow.py@@ -16,6 +16,7 @@ from vibe.upgrade import (get_latest_version_info,get_restart_command,get_running_vibe_path,+ get_safe_cwd,)@@ -256,3 +257,17 @@ def test_cmd_upgrade_skips_install_when_already_latest(monkeypatch):monkeypatch.setattr(cli.subprocess, "run", fail_run)assert cli.cmd_upgrade() == 0+++def test_get_safe_cwd_returns_absolute_existing_dir():+ cwd = get_safe_cwd()+ assert os.path.isabs(cwd)+ assert os.path.isdir(cwd)+++def test_get_safe_cwd_falls_back_when_home_invalid(monkeypatch):+ monkeypatch.setenv("HOME", "/nonexistent_dir_for_test")+ cwd = get_safe_cwd()+ assert os.path.isabs(cwd)+ assert os.path.isdir(cwd)+ assert cwd != "/nonexistent_dir_for_test"diff --git a/vibe/api.py b/vibe/api.pyindex 247215ffc..9be6837ea 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -26,7 +26,13 @@ from vibe.opencode_config import (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+from vibe.upgrade import (+ build_upgrade_plan,+ get_latest_version_info,+ get_restart_shell_command,+ get_running_vibe_path,+ get_safe_cwd,+)logger = logging.getLogger(__name__)@@ -656,10 +662,10 @@ 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("~")+ # Use a stable 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 = get_safe_cwd()try:result = subprocess.run(diff --git a/vibe/cli.py b/vibe/cli.pyindex dc7a99c45..863677d1d 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -20,7 +20,7 @@ from config.v2_config import (V2Config,)from vibe import __version__, api, runtime-from vibe.upgrade import build_upgrade_plan, cache_running_vibe_path, get_latest_version_info+from vibe.upgrade import build_upgrade_plan, cache_running_vibe_path, get_latest_version_info, get_safe_cwdlogger = logging.getLogger(__name__)@@ -652,9 +652,9 @@ 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("~")+ # Use a stable 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 = get_safe_cwd()try:result = subprocess.run(plan.command, capture_output=True, text=True, env=plan.env, cwd=safe_cwd)diff --git a/vibe/upgrade.py b/vibe/upgrade.pyindex 11519d859..0933ac8ef 100644--- a/vibe/upgrade.py+++ b/vibe/upgrade.py@@ -5,6 +5,7 @@ import osimport shleximport shutilimport sys+import tempfileimport urllib.requestfrom collections.abc import Mappingfrom dataclasses import dataclass@@ -233,3 +234,17 @@ def build_upgrade_plan(env=dict(base_env or os.environ),method="pip",)+++def get_safe_cwd() -> str:+ """Return a stable, existing absolute directory for subprocess cwd.++ The vibe service process cwd may be inside the uv tool venv directory,+ which uv deletes and recreates during upgrade. Using the home directory+ avoids 'Current directory does not exist' errors. Falls back to the+ system temp directory or ``/`` when HOME is unset or invalid.+ """+ for candidate in (os.path.expanduser("~"), tempfile.gettempdir(), "/"):+ if os.path.isabs(candidate) and os.path.isdir(candidate):+ return candidate+ return "/"