Skip to content

fix(install): 修复 macOS 两个阻断 bug + 四脚本版本级缓存原子写 - #466

Merged
bigbrother666sh merged 5 commits into
TeamWiseFlow:masterfrom
bigbrother666sh:master
Aug 6, 2026
Merged

fix(install): 修复 macOS 两个阻断 bug + 四脚本版本级缓存原子写#466
bigbrother666sh merged 5 commits into
TeamWiseFlow:masterfrom
bigbrother666sh:master

Conversation

@bigbrother666sh

Copy link
Copy Markdown
Member

背景

macOS 上执行一键安装脚本遭遇两个阻断 bug,导致安装未成功完成。同时四个安装脚本(.sh / .ps1 × GitHub / atomgit)缺少版本级 tarball 缓存,重跑会重复下载 120MB。

修复两个阻断 bug

Bug 1: pip externally-managed-environment(PEP 668)

macOS Homebrew python3 是 PEP 668 标记的 externally-managed 环境,pip install --user 仍被拒。

修法(install_python_deps):

  • 预探测:用 sysconfig.get_path("include") 找 stdlib 目录,检查 EXTERNALLY-MANAGED 标记文件,命中主动加 --break-system-packages
  • 兜底:pip 报 externally-managed 退出码 1 时自动重试加 flag
  • --user 限目标目录,不碰系统 site-packages,安全

Bug 2: bash: line 1738: OPENCLAW_HOME: unbound variable

根因:install_gateway_and_envunset OPENCLAW_HOME 误伤了脚本顶部定义的内部变量(第 1202 行)。那个内部变量本就只赋值未 export,不会传给引擎子进程,unset 纯误伤——删掉之后下面 ${OPENCLAW_HOME//...}set -u 下直接报 unbound 退出。

修法:删掉 unset OPENCLAW_HOME,保留 warning 提示用户清理 shell 环境。

四脚本加版本级缓存 + 原子写

脚本 路线 缓存目录 原子写
install.sh GitHub tarball ~/.xiaobei/cache/ .partmv -f
install-atomgit.sh atomgit tarball 同上 同上
install.ps1 GitHub tarball (Win) 同上 .partMove-Item -Force
install-atomgit.ps1 atomgit tarball (Win) 同上 同上
  • 同 tag 重跑命中缓存跳过 120MB 下载
  • 原子写:先下 .part 临时文件,成功后 rename 到 cached
  • 断网不会留半截损坏文件被下次误判为完整缓存

校验

  • bash -n 两个 .sh 语法校验通过
  • Python 词法剥离器校验两个 .ps1 括号/大括号平衡:BALANCED

备注

此 PR 为修补性质,请暂不要触发 auto release / tarball 重建,合入后我会手动确认 release 流程。

foxdanzhang-tech and others added 4 commits August 6, 2026 15:45
…W_HOME to bash

Three fixes to the Windows PowerShell install scripts (install.ps1 and
install-atomgit.ps1):

1. Remove UTF-8 BOM from both .ps1 files.
   Under `irm | iex`, irm does not strip the BOM, and iex treats the 3 BOM
   bytes as the first chars of a command name, so the first line `#` is
   parsed as an unknown command and errors (though it does not block the
   install). Without BOM, both `irm | iex` and local `powershell -File`
   work fine.

2. Translate all comments from Chinese to English (pure ASCII).
   Without BOM, Windows PowerShell 5.1 reads the file using the system ANSI
   code page (GBK on Chinese systems). Chinese comments in UTF-8 get
   misread as GBK, producing mojibake that cascades into parsing errors.
   English (ASCII) comments avoid this entirely in any encoding.

3. Explicitly pass OPENCLAW_HOME to bash in Run-SetupCrew (fixes ENOENT).
   setup-crew.sh uses OPENCLAW_HOME internally to resolve CONFIG_PATH and
   does NOT read OPENCLAW_STATE_DIR. Previously install.ps1 only set
   OPENCLAW_STATE_DIR, so setup-crew.sh fell back to $HOME/.openclaw.
   Under Git Bash's MSYS path conversion plus a Chinese username, this
   produced a bogus path like
   C:\c\Users\<garbled>\.openclaw\openclaw.json (ENOENT).
   Now we explicitly set $env:OPENCLAW_HOME to a forward-slash path before
   calling bash, and clear it immediately after so subsequent gateway/daemon
   phases do not inherit it (the engine would nest-append /.openclaw).

Co-Authored-By: AtomCode (GLM-5.2) <noreply@atomgit.com>
fix(install): remove BOM, translate comments to English, pass OPENCLA…
## 修复两个阻断 bug

1. pip PEP 668 externally-managed-environment(macOS Homebrew python)
   - install_python_deps 探测 EXTERNALLY-MANAGED 标记,命中加 --break-system-packages
   - 兜底:pip 报 externally-managed 退出码 1 时自动重试加 flag
   - --user 限目标目录,不碰系统 site-packages,安全

2. bash: OPENCLAW_HOME: unbound variable(install_gateway_and_env)
   - 根因:configure_gateway 里 unset OPENCLAW_HOME 误伤脚本顶部定义的内部变量
   - 内部变量本就只赋值未 export,不会传给引擎子进程,unset 纯误伤
   - 修法:删掉 unset,保留 warning 提示用户清理 shell 环境

## 四个安装脚本加版本级缓存 + 原子写

| 脚本 | 路线 | 缓存 | 原子写 |
|------|------|------|--------|
| install.sh | GitHub tarball | ~/.xiaobei/cache/ | .part → mv -f |
| install-atomgit.sh | atomgit tarball | 同上 | 同上 |
| install.ps1 | GitHub tarball (Win) | 同上 | .part → Move-Item -Force |
| install-atomgit.ps1 | atomgit tarball (Win) | 同上 | 同上 |

- 同 tag 重跑命中缓存跳过 120MB 下载
- 原子写:先下 .part 临时文件,成功后 rename 到 cached
- 断网不会留半截损坏文件被下次误判为完整缓存

Co-Authored-By: AtomCode (GLM-5.2) <noreply@atomgit.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 3 committers have signed the CLA.

✅ bigbrother666sh
❌ codes-factory-of-bg
❌ foxdanzhang-tech


codes-factory-of-bg seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

- 移除 login-manager 技能引用,改为通用的"重新登录"
- 精简失效平台汇报段落,去掉冗余说明
- wechat-channel 文案微调

Co-Authored-By: AtomCode (GLM-5.2) <noreply@atomgit.com>
@bigbrother666sh
bigbrother666sh merged commit c49d933 into TeamWiseFlow:master Aug 6, 2026
2 of 3 checks passed
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.

3 participants