Skip to content

fix: 修复 Windows 首次安装同步失败#212

Closed
YIOYIOIOI wants to merge 1 commit intocft0808:mainfrom
YIOYIOIOI:fix/windows-first-sync
Closed

fix: 修复 Windows 首次安装同步失败#212
YIOYIOIOI wants to merge 1 commit intocft0808:mainfrom
YIOYIOIOI:fix/windows-first-sync

Conversation

@YIOYIOIOI
Copy link
Copy Markdown
Contributor

背景

在 Windows 环境下按仓库当前安装流程执行 install.ps1 时,首次安装后经常出现 First-Sync 未正确完成的问题,表现为:

  • data/agent_config.json 为空或未正确生成
  • data/officials_stats.json 未生成
  • data/live_status.json 内容不完整或为空
  • 终端看起来完成安装,但首次同步结果不正确

另外,在当前安装流程里,scripts/sync_agent_config.pyinstall.ps1workspace-*/scripts 存在重复处理,容易导致后续脚本同步逻辑与目录链接逻辑冲突。

本 PR 修改

1. install.ps1

Windows 下优先使用 python,不再优先使用 python3

原因:
在部分 Windows 环境中,python3 会解析到 WindowsApps 的启动别名,而不是实际可用的 Python 解释器,导致 First-Sync 阶段运行脚本异常或未正确执行。

2. scripts/sync_agent_config.py

注释掉 sync_scripts_to_workspaces() 调用。

原因:
install.ps1 已经在安装阶段将 workspace-*/scripts 连接到项目 scripts 目录,再执行逐文件 symlink 同步会形成重复处理。在 Windows 下这会带来明显冲突风险。

3. scripts/sync_officials_stats.py

读取 JSON 文件时显式使用 encoding='utf-8'

原因:
否则在 Windows 环境中读取 openclaw.json 时可能因编码问题失败,并静默回退到默认模型值,导致 officials_stats.json 中所有官员模型错误显示为 anthropic/claude-sonnet-4-6

结果

在本地 Windows 环境重新验证后:

  • 第一次执行 install.ps1 可成功完成安装
  • 手动执行 First-Sync 三个脚本可正常通过
  • agent_config.jsonofficials_stats.jsonlive_status.json 可正常生成
  • officials_stats.json 中模型信息可正确读取 openclaw.json 中的配置

说明

这个 PR 只包含与“Windows 首次安装同步失败”直接相关的 3 个最小修改,不包含其他额外功能调整。

@YIOYIOIOI
Copy link
Copy Markdown
Contributor Author

这是从更大的 Windows 兼容性修复中拆出来的一个小 PR,只保留了与“首次安装后 First-Sync 无法正确完成”直接相关的最小修改,便于单独 review 和合并。

Copy link
Copy Markdown
Owner

@cft0808 cft0808 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢 PR!几点反馈:

  1. sync_scripts_to_workspaces() 注释掉 — PR #218 已合并,从根本上修复了符号链接自引用问题,不再需要禁用此功能。注释掉会导致 Linux/Mac 用户的 workspace 脚本无法同步。
  2. install.ps1 python 优先级调整 — 这个改动合理 ✅
  3. encoding='utf-8' 修复 — 这个改动合理 ✅

建议:请基于最新 main(已含 #218 修复)rebase,移除对 sync_scripts_to_workspaces() 的注释,只保留 install.ps1 和 encoding 两个修复,即可合并。

@YIOYIOIOI YIOYIOIOI force-pushed the fix/windows-first-sync branch 2 times, most recently from 222662b to 098b520 Compare March 30, 2026 12:22
cft0808 added a commit that referenced this pull request Mar 30, 2026
Bug 修复:
- Fix #232: court_discuss.py 添加 from __future__ import annotations 兼容 Python 3.9
- Fix #233: Dockerfile 添加 channels 模块 COPY 解决 Docker 运行时 ModuleNotFoundError
- Fix #234: sync_agent_config.py 将 dispatchChannel 默认值从 'feishu' 改为空字符串
- Fix #241: sync_agent_config.py 收集 defaults.models 中的所有可用模型到看板选择器

社区贡献 (cherry-pick):
- PR #239 (@ElninoZhong): 添加 workflow state vs execution ownership 文档
- PR #237 (@ElninoZhong): 修复 feishu 默认值问题
- PR #212 (@YIOYIOIOI): Windows install.ps1 优先 python 命令 + UTF-8 编码修复

依赖更新 (Dependabot):
- actions/checkout v4 → v6
- docker/setup-buildx-action v3 → v4
- docker/build-push-action v5 → v7
- actions/labeler v5 → v6
- actions/stale v9 → v10
@cft0808
Copy link
Copy Markdown
Owner

cft0808 commented Mar 30, 2026

感谢 @YIOYIOIOI 的 Windows 兼容性修复!已 cherry-pick 合入 main (commit 0f1c24b):

  • install.ps1:Windows 下优先查找 python 命令
  • sync_officials_stats.py:添加 encoding='utf-8' 避免 Windows GBK 编码问题

@cft0808 cft0808 closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants