fix(macos): use Apple-standard app-data dir for xworkmate-bridge base
Switch the macOS bridge base dir to the Apple-standard per-user location $HOME/Library/Application Support/cloud-neutral/xworkmate-bridge, while Linux keeps /opt/cloud-neutral/xworkmate-bridge. Applied both as the Darwin -e override in setup-ai-workspace-all-in-one.sh (the lever that reaches the curl|bash path) and as an OS-conditional role default. Updates TC-MAC-012 and the progress report with the not-pushed root cause of the 19:09 re-failure.
This commit is contained in:
parent
d094c27b86
commit
470e5163f5
@ -102,8 +102,10 @@
|
||||
|------|------|
|
||||
| **触发文件** | `setup-ai-workspace-all-in-one.sh` → `roles/vhosts/xworkmate_bridge`(变量 `xworkmate_bridge_base_dir`) |
|
||||
| **触发报错** | `TASK [roles/vhosts/xworkmate_bridge/ : Ensure xworkmate-bridge base directory exists]` → `There was an issue creating /opt/cloud-neutral as requested: [Errno 13] Permission denied: b'/opt/cloud-neutral'` |
|
||||
| **根因** | `xworkmate_bridge_base_dir` 默认硬编码为 `/opt/cloud-neutral/xworkmate-bridge`,macOS 以 `ansible_become=false` 运行,无权写入 `/opt`。该 base dir 同时被 `config.yaml`、launchd plist 的 `WorkingDirectory` 引用 |
|
||||
| **修复方案** | 沿用既有 macOS 适配约定(`gateway_openclaw_home`、`agent_skills_home` 等均在脚本 Darwin 分支以 `-e` 重定向到 `$HOME`),在 `setup-ai-workspace-all-in-one.sh` 的 Darwin 分支注入 `-e xworkmate_bridge_base_dir=$HOME/.local/state/cloud-neutral/xworkmate-bridge`,无需改动独立的 playbooks 仓库即可在运行时覆盖默认值 |
|
||||
| **根因** | `xworkmate_bridge_base_dir` 默认硬编码为 `/opt/cloud-neutral/xworkmate-bridge`,macOS 以 `ansible_become=false` 运行,无权写入 `/opt`;且 `/opt` 并非 macOS 标准目录。该 base dir 同时被 `config.yaml`、launchd plist 的 `WorkingDirectory` 引用 |
|
||||
| **目录策略** | Linux 保持 `/opt/cloud-neutral/xworkmate-bridge`;macOS 改用 Apple 标准的用户级应用数据目录 `~/Library/Application Support/cloud-neutral/xworkmate-bridge` |
|
||||
| **修复方案** | 双层:①`setup-ai-workspace-all-in-one.sh` 的 Darwin 分支注入 `-e xworkmate_bridge_base_dir="$HOME/Library/Application Support/cloud-neutral/xworkmate-bridge"`(`curl \| bash` 拉取的是本仓库脚本,playbooks 来自独立仓库,故脚本侧 `-e` 是该路径下唯一可生效的修复点);②role `defaults/main.yml` 将默认值改为按 `ansible_os_family` 的三元表达式,使离线/本地 playbook 路径亦正确 |
|
||||
| **生效前提** | `curl \| bash` 从 GitHub `main` 拉取脚本,修复必须先 push 到 `ai-workspace-lab/xworkspace-console` 的 `main`;否则远端仍是旧脚本(extra-vars 优先级最高,若 `-e` 已执行则绝不会回落到 `/opt`,由此可判定执行的是未修复的远端脚本) |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@ -59,3 +59,34 @@ Ansible extra-vars 优先级高于 role defaults,因此对在线(`curl | bas
|
||||
1. 在 Mac 上重跑 `COMBO-001` 验证 bridge 任务通过。
|
||||
2. 若下一阻塞点为 `/etc/caddy` 权限,可按同样方式(Darwin 守卫或 `-e` 重定向)处理。
|
||||
3. 未纳入本次提交:预先存在且无关的 `create-ai-workspace-offline-package.sh`(新增 `npm`)改动,以及生成的离线包目录。
|
||||
|
||||
---
|
||||
|
||||
## 7. 复盘更新(19:09 二次失败)
|
||||
|
||||
**现象**:用户再次执行 `curl -sfL .../main/scripts/setup-ai-workspace-all-in-one.sh | bash -`,仍报相同的 `/opt/cloud-neutral` `Errno 13`。
|
||||
|
||||
**定位**:
|
||||
- `git log origin/main..HEAD` 显示 `cf97344`、`d094c27` 两个提交**仅在本地、未 push**。
|
||||
- `curl | bash` 拉取的是 GitHub `main` 上的脚本,即未修复版本;因此 `-e` 覆盖根本没进入本次运行。
|
||||
- 佐证:Ansible extra-vars 优先级最高,若 `-e xworkmate_bridge_base_dir` 已执行,绝不可能回落到 role 默认的 `/opt`。故可判定执行的是未修复的远端脚本。
|
||||
- 本沙箱无法 push(SSH 22 端口对 github.com 被禁),需在用户机器上 push。
|
||||
|
||||
**策略调整(按用户要求区分平台 + 采用苹果标准目录)**:
|
||||
- Linux:保持 `/opt/cloud-neutral/xworkmate-bridge`。
|
||||
- macOS:改用 Apple 标准用户级应用数据目录 `~/Library/Application Support/cloud-neutral/xworkmate-bridge`(取代上一版的 `~/.local/state/...`)。
|
||||
- 实现:脚本 Darwin 分支 `-e` 覆盖更新为上述路径;同时把 role `defaults/main.yml` 默认值改为按 `ansible_os_family` 的三元表达式(离线/本地 playbook 路径亦正确)。Jinja 渲染与 `bash -n` 均已验证。
|
||||
|
||||
**让修复立即生效的两种方式(择一)**:
|
||||
|
||||
```bash
|
||||
# 方式 A:本地仓库已含修复,直接跑本地脚本(无需等 push)
|
||||
bash "/Users/shenlan/workspaces/ai-workspace-lab/xworkspace-console/scripts/setup-ai-workspace-all-in-one.sh"
|
||||
|
||||
# 方式 B:把修复 push 到 main,之后 curl | bash 即可生效
|
||||
cd /Users/shenlan/workspaces/ai-workspace-lab/xworkspace-console
|
||||
git push origin main
|
||||
curl -sfL https://raw.githubusercontent.com/ai-workspace-lab/xworkspace-console/main/scripts/setup-ai-workspace-all-in-one.sh | bash -
|
||||
```
|
||||
|
||||
> 注:方式 A 走 `curl | bash` 之外的本地执行路径,脚本侧 `-e` 覆盖会直接生效;role 默认的三元表达式则覆盖离线 `PLAYBOOK_DIR` 场景。
|
||||
|
||||
@ -1982,9 +1982,10 @@ if [ "$(detect_os)" = "darwin" ]; then
|
||||
ANSIBLE_EXTRA_VARS+=("-e" "gateway_openclaw_compile_cache_dir=$HOME/.cache/openclaw-compile-cache")
|
||||
ANSIBLE_EXTRA_VARS+=("-e" "gateway_openclaw_service_path=$DARWIN_SERVICE_PATH")
|
||||
# XWorkMate Bridge writes its runtime data under a base dir that defaults to
|
||||
# /opt/cloud-neutral on Linux. macOS runs become=false, so /opt is not
|
||||
# writable; relocate the bridge base dir under the user's home instead.
|
||||
ANSIBLE_EXTRA_VARS+=("-e" "xworkmate_bridge_base_dir=$HOME/.local/state/cloud-neutral/xworkmate-bridge")
|
||||
# /opt/cloud-neutral on Linux. That path is fine on Linux, but on macOS it
|
||||
# is both non-writable under become=false and non-standard for the platform.
|
||||
# Relocate it to the Apple-standard per-user app data location instead.
|
||||
ANSIBLE_EXTRA_VARS+=("-e" "xworkmate_bridge_base_dir=$HOME/Library/Application Support/cloud-neutral/xworkmate-bridge")
|
||||
else
|
||||
LINUX_CONSOLE_USER="$(linux_default_console_user)"
|
||||
LINUX_CONSOLE_HOME="$(linux_default_console_home "$LINUX_CONSOLE_USER")"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user