fix(portable/mac): setup.sh 装不上 + Bonjour 广播 + 首次启动浏览器不开
在 macmini (Apple Silicon, macOS 15.6.1) 实测发现并修复 3 个 Mac 版问题: 1. setup.sh 漏 --ignore-scripts → 装不上 openclaw(致命) openclaw 的 preinstall 脚本会调系统 `node`,但便携版用 app/runtime 下的 node(不在 PATH),未装 Node 的 Mac 用户 → "node: command not found" code 127。 两条 npm install 补 --ignore-scripts --no-audit --no-fund --omit=dev,与 Mac-Start.command 的 fallback install 对齐。 2. Mac-Start.command 没关 Bonjour → mDNS 自动对外广播 macOS 上 bonjour 插件 auto-start(Win/Linux 是 opt-in)。实测日志: `bonjour: advertised ... state=announcing` + `no IPv4 address available on utun12`。本地用 Dashboard 不需要 LAN 发现。补 OPENCLAW_DISABLE_BONJOUR=1 (Windows-Start.bat 早已设)。 3. 首次启动浏览器不自动打开(同 issue #46/#48,此前误判 Mac 无此问题) 首次启动实测 94.5s(staging 35 个 bundled deps),但浏览器轮询只等 15s (30×0.5s) 就放弃。改为最多等 ~3 分钟 (180×1s),加"首次启动需 30-90 秒" 提示,超时回退打开 Config Center。 三处修复均已在 macmini 端到端重测通过。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -95,6 +95,11 @@ fi
|
|||||||
export OPENCLAW_HOME="$DATA_DIR"
|
export OPENCLAW_HOME="$DATA_DIR"
|
||||||
export OPENCLAW_STATE_DIR="$STATE_DIR"
|
export OPENCLAW_STATE_DIR="$STATE_DIR"
|
||||||
export OPENCLAW_CONFIG_PATH="$CONFIG_FILE"
|
export OPENCLAW_CONFIG_PATH="$CONFIG_FILE"
|
||||||
|
# U-Claw opens the local dashboard directly; disable mDNS/Bonjour discovery.
|
||||||
|
# On macOS the bonjour plugin auto-starts and advertises the gateway on the LAN
|
||||||
|
# (_openclaw-gw._tcp.local), which is unnecessary for local use and triggers
|
||||||
|
# "no IPv4 address available on utunN" warnings on machines with VPN/Tailscale.
|
||||||
|
export OPENCLAW_DISABLE_BONJOUR=1
|
||||||
|
|
||||||
# ---- 7. Check dependencies ----
|
# ---- 7. Check dependencies ----
|
||||||
if [ ! -d "$CORE_DIR/node_modules" ]; then
|
if [ ! -d "$CORE_DIR/node_modules" ]; then
|
||||||
@@ -148,17 +153,38 @@ OPENCLAW_MJS="$CORE_DIR/node_modules/openclaw/openclaw.mjs"
|
|||||||
"$NODE_BIN" "$OPENCLAW_MJS" gateway run --allow-unconfigured --force --port $PORT &
|
"$NODE_BIN" "$OPENCLAW_MJS" gateway run --allow-unconfigured --force --port $PORT &
|
||||||
GW_PID=$!
|
GW_PID=$!
|
||||||
|
|
||||||
# ---- 11. Wait for gateway, then open browser ----
|
# ---- 11. 是否已配置模型?openclaw.json 含 "providers" 即视为已配置 (issue #24) ----
|
||||||
for i in $(seq 1 30); do
|
# 已配置:只开 Dashboard,不再每次弹配置页。未配置(首次):开 Config Center 引导填 Key。
|
||||||
sleep 0.5
|
MODEL_CONFIGURED=0
|
||||||
|
if grep -q '"providers"' "$CONFIG_FILE" 2>/dev/null; then
|
||||||
|
MODEL_CONFIGURED=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ---- 12. Wait for gateway, then open browser ----
|
||||||
|
# 首次启动会 staging ~35 个 bundled deps,慢盘上实测可达 90 秒以上,期间端口还没
|
||||||
|
# LISTENING。轮询上限必须覆盖这段,否则浏览器在 gateway ready 前就放弃打开,用户
|
||||||
|
# 看到"拒绝连接"以为坏了(同 Windows issue #46/#48)。最多等 ~3 分钟(180×1s)。
|
||||||
|
echo -e " ${YELLOW}首次启动需准备运行环境,约 30-90 秒,请稍候...${NC}"
|
||||||
|
GATEWAY_READY=0
|
||||||
|
for i in $(seq 1 180); do
|
||||||
if curl -s -o /dev/null "http://127.0.0.1:$PORT/" 2>/dev/null; then
|
if curl -s -o /dev/null "http://127.0.0.1:$PORT/" 2>/dev/null; then
|
||||||
# Open Dashboard
|
GATEWAY_READY=1
|
||||||
|
if [ "$MODEL_CONFIGURED" = "1" ]; then
|
||||||
|
# 已配置:只开 Dashboard
|
||||||
open "http://127.0.0.1:$PORT/#token=uclaw" 2>/dev/null || true
|
open "http://127.0.0.1:$PORT/#token=uclaw" 2>/dev/null || true
|
||||||
# Open Config Center
|
else
|
||||||
|
# 首次:开 Config Center 引导填 Key
|
||||||
open "http://127.0.0.1:18788/" 2>/dev/null || true
|
open "http://127.0.0.1:18788/" 2>/dev/null || true
|
||||||
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
sleep 1
|
||||||
done
|
done
|
||||||
|
if [ "$GATEWAY_READY" != "1" ]; then
|
||||||
|
# 超时回退:gateway 还没就绪也别让用户干等,先开 Config Center
|
||||||
|
echo -e " ${YELLOW}Gateway 启动较慢,先打开配置中心...${NC}"
|
||||||
|
open "http://127.0.0.1:18788/" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
echo -e " ${GREEN}════════════════════════════════${NC}"
|
echo -e " ${GREEN}════════════════════════════════${NC}"
|
||||||
echo -e " ${GREEN}🦞 U-Claw is running!${NC}"
|
echo -e " ${GREEN}🦞 U-Claw is running!${NC}"
|
||||||
|
|||||||
@@ -131,9 +131,12 @@ PKGJSON
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Install with China mirror(缓存留盘内,拔盘不留痕)
|
# Install with China mirror(缓存留盘内,拔盘不留痕)
|
||||||
|
# --ignore-scripts 必须加:openclaw 的 preinstall 脚本会调系统 `node`,但便携版
|
||||||
|
# 用的是 app/runtime 下的 node(不在 PATH),未装 Node 的 Mac 用户会因
|
||||||
|
# "node: command not found" 安装失败 (code 127)。与 Mac-Start.command 的 fallback 对齐。
|
||||||
NODE_BIN="$NODE_TARGET/bin/node"
|
NODE_BIN="$NODE_TARGET/bin/node"
|
||||||
NPM_BIN="$NODE_TARGET/bin/npm"
|
NPM_BIN="$NODE_TARGET/bin/npm"
|
||||||
npm_config_cache="$APP_DIR/.npm-cache" "$NODE_BIN" "$NPM_BIN" install --prefix "$CORE_DIR" --registry="$MIRROR"
|
npm_config_cache="$APP_DIR/.npm-cache" "$NODE_BIN" "$NPM_BIN" install --prefix "$CORE_DIR" --registry="$MIRROR" --ignore-scripts --no-audit --no-fund --omit=dev
|
||||||
|
|
||||||
echo -e " ${GREEN}✓${NC} OpenClaw 安装完成"
|
echo -e " ${GREEN}✓${NC} OpenClaw 安装完成"
|
||||||
fi
|
fi
|
||||||
@@ -145,7 +148,7 @@ else
|
|||||||
echo -e " ${CYAN}↓${NC} 安装 QQ 插件..."
|
echo -e " ${CYAN}↓${NC} 安装 QQ 插件..."
|
||||||
NODE_BIN="$NODE_TARGET/bin/node"
|
NODE_BIN="$NODE_TARGET/bin/node"
|
||||||
NPM_BIN="$NODE_TARGET/bin/npm"
|
NPM_BIN="$NODE_TARGET/bin/npm"
|
||||||
npm_config_cache="$APP_DIR/.npm-cache" "$NODE_BIN" "$NPM_BIN" install @sliverp/qqbot@latest --prefix "$CORE_DIR" --registry="$MIRROR" 2>/dev/null || true
|
npm_config_cache="$APP_DIR/.npm-cache" "$NODE_BIN" "$NPM_BIN" install @sliverp/qqbot@latest --prefix "$CORE_DIR" --registry="$MIRROR" --ignore-scripts --no-audit --no-fund --omit=dev 2>/dev/null || true
|
||||||
echo -e " ${GREEN}✓${NC} QQ 插件安装完成"
|
echo -e " ${GREEN}✓${NC} QQ 插件安装完成"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user