修复 macOS 上的“Host daemon is not reachable”
当 Quick Setup 已安装包,但 Doctor 无法访问 Daemon 或找到 attach socket 时,恢复 Moshline LaunchAgent。
更新时间: 2026-07-23适用范围: macOS LaunchAgent com.moshline.host
完成后
LaunchAgent 已加载、Daemon 在本机响应、attach socket 存在,并且 moshline-host doctor 的 Host daemon 检查返回 PASS。
确认是否属于这个故障
这表示包和 Hook 文件可能已经安装,但后台服务没有启动。先修复 Daemon,再检查 tmux、审批或 App。
典型 Doctor 输出
$ FAIL Host daemon is not reachable: fetch failed
$ PASS Multiplexer adapter check waits for the host daemon
$ FAIL Terminal attach socket is missing; restart the host daemon1. 检查已安装服务
只读检查
$ moshline-host version
$ moshline-host doctor
$ launchctl print "gui/$(id -u)/com.moshline.host"
$ plutil -p "$HOME/Library/LaunchAgents/com.moshline.host.plist"
$ ls -ld "$HOME/Library/Logs" "$HOME/Library/Logs/Moshline"
$ tail -n 100 "$HOME/Library/Logs/Moshline/host.log"2. 验证 Node 与 CLI 的绝对路径
LaunchAgent 保存绝对路径。NVM 与 asdf 可以正常工作,直到对应 Node 版本被删除。查看 plist 的 ProgramArguments[0] 和 [1],确认两个文件都存在且可执行。
对比当前 Shell 路径
$ command -v node
$ command -v moshline-host
$ node --version
$ moshline-host version3. 只重新加载 Moshline LaunchAgent
以下命令只重启 Moshline Host Helper 服务,不会删除仓库、Agent 会话、SSH 密钥或 Host 配置。
服务修复
$ mkdir -p "$HOME/Library/Logs/Moshline"
$ launchctl bootout "gui/$(id -u)" "$HOME/Library/LaunchAgents/com.moshline.host.plist" 2>/dev/null || true
$ launchctl bootstrap "gui/$(id -u)" "$HOME/Library/LaunchAgents/com.moshline.host.plist"
$ launchctl kickstart -k "gui/$(id -u)/com.moshline.host"4. 验证健康状态与 Attach
预期检查
$ launchctl print "gui/$(id -u)/com.moshline.host" | head -40
$ curl -fsS http://127.0.0.1:24000/health
$ tail -n 100 "$HOME/Library/Logs/Moshline/host.log"
$ moshline-host doctor5. 服务仍无法启动时重跑 Quick Setup
Quick Setup 会刷新 package、service definition、Hook 与保存的可执行文件路径,同时保留已配对 Host 身份和无关 Provider Hook。
- npm 报权限错误时,旧全局安装可能由 root 持有。
- 日志出现 EADDRINUSE 时,先识别占用 24000 端口的进程。
- curl 正常但 Doctor 报主机身份错误时,确认 Daemon 与 ~/.config/moshline/host.json 属于同一用户。
- Remote Login 关闭时,先打开再重复手机生成的安装命令。
修复安装
$ curl -fsSL https://raw.githubusercontent.com/NomadShell/Scripts/main/quick-setup.sh | bash
$ moshline-host doctor参考路径
| 项目 | 路径或标签 |
|---|---|
| LaunchAgent label | com.moshline.host |
| LaunchAgent plist | ~/Library/LaunchAgents/com.moshline.host.plist |
| Host config | ~/.config/moshline/host.json |
| Daemon log | ~/Library/Logs/Moshline/host.log |
| 默认本机健康端口 | 127.0.0.1:24000 |
| Attach socket | ~/.local/share/moshline/moshline-host.sock |
相关文档