fix(desktop): stop backend writing into the .app bundle

This commit is contained in:
zhayujie
2026-07-08 01:59:08 +08:00
parent efbabfcace
commit ca404aeb24
3 changed files with 31 additions and 4 deletions

View File

@@ -688,8 +688,11 @@ class CowCliPlugin(Plugin):
if resolved:
updates["bot_type"] = resolved
project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
config_path = os.path.join(project_root, "config.json")
# Write to the data dir (~/.cow in desktop, project root otherwise), not
# __file__-relative — the latter lives inside the read-only .app bundle
# when frozen and writing there breaks the macOS code-signature seal.
from config import get_data_root
config_path = os.path.join(get_data_root(), "config.json")
try:
with open(config_path, "r", encoding="utf-8") as f:
file_config = _json.load(f)
@@ -1630,8 +1633,9 @@ class CowCliPlugin(Plugin):
conf()["knowledge"] = enabled
project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
config_path = os.path.join(project_root, "config.json")
# Data dir (~/.cow in desktop), not __file__-relative — see _config_set.
from config import get_data_root
config_path = os.path.join(get_data_root(), "config.json")
try:
with open(config_path, "r", encoding="utf-8") as f:
file_config = _json.load(f)