解决openclaw以及插件安装的报错

1 安装微信等插件报错 SafeOpenError: path is not a regular file under root

csharp 复制代码
$ npx -y @tencent-weixin/openclaw-weixin-cli@latest install  
[openclaw-weixin] 已找到本地安装的 openclaw  
[openclaw-weixin] 正在安装插件...  
[openclaw-weixin] 插件安装失败,请手动执行:  
failed to extract archive: SafeOpenError: path is not a regular file under root

openclaw plugins install "@tencent-weixin/openclaw-weixin"
less 复制代码
$ openclaw plugins install "@tencent-weixin/openclaw-weixin"  
10:09:54 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes  
10:09:54 [plugins] feishu_chat: Registered feishu_chat tool  
10:09:54 [plugins] feishu_wiki: Registered feishu_wiki tool  
10:09:54 [plugins] feishu_drive: Registered feishu_drive tool  
10:09:54 [plugins] feishu_bitable: Registered bitable tools  
10:09:54 [plugins] [content-security] 状态目录: /Users/yangjie01/.openclaw  
10:09:54 [plugins] [content-security] 注册失败:缺少必要配置。endpoint=<https://jprx.m.qq.com/data/4064/forward>, token=空  
[wechat-access] 腾讯通路插件已注册

🦞 OpenClaw 2026.3.11 (29dc654) --- No $999 stand required.

Downloading @tencent-weixin/openclaw-weixin...  
Extracting /var/folders/ls/4yw8p6vx7vv1xs_lt4h9rx48g4lvj2/T/openclaw-npm-pack-dUwsva/tencent-weixin-openclaw-weixin-1.0.2.tgz...  
failed to extract archive: SafeOpenError: path is not a regular file under root

通过 claude-4.6-Sonnet 解决

问题总结:OpenClaw 插件安装失败

根本原因

OpenClaw 在 macOS 上安装插件时,使用了一个 Python 脚本来做原子文件写入 (runPinnedWriteHelper),该脚本用到了 os.open(path, flags, dir_fd=dir_fd) 的 dir_fd 参数。

dir_fd 是 Linux 特有特性,macOS 的 Python 不支持,导致 Python 脚本崩溃:

csharp 复制代码
NotImplementedError: dir_fd unavailable on this platform

这个错误被层层包装后,以误导性的错误信息呈现给用户:

vbnet 复制代码
failed to extract archive: SafeOpenError: path is not a regular file under root

解决方案

⚠️ 将以下路径中的 {USERNAME} 替换为你的用户名,{NODE_VERSION} 替换为你的 Node.js 版本(如 v24.14.0)

bash 复制代码
/Users/{USERNAME}/.nvm/versions/node/{NODE_VERSION}/lib/node_modules/openclaw/dist/

Patch 1 --- install-safe-path-xC--QTS5.js:跳过非文件条目

scss 复制代码
sed -i '' 's/if (!sourceStat.isFile()) throw new Error(`archive staging contains unsupported entry: ${originalPath}`);/if (!sourceStat.isFile()) { continue; }/' \
  /Users/{USERNAME}/.nvm/versions/node/{NODE_VERSION}/lib/node_modules/openclaw/dist/install-safe-path-xC--QTS5.js

Patch 2 --- windows-spawn-oQqooioe.js:新建文件时跳过 isFile 检查

arduino 复制代码
sed -i '' '469s/if (!stat.isFile()) throw new SafeOpenError("invalid-path", "path is not a regular file under root");/if (!stat.isFile() && !createdForWrite) throw new SafeOpenError("invalid-path", "path is not a regular file under root");/' \
  /Users/{USERNAME}/.nvm/versions/node/{NODE_VERSION}/lib/node_modules/openclaw/dist/windows-spawn-oQqooioe.js

sed -i '' '473s/if (lstat.isSymbolicLink() || !lstat.isFile()) throw new SafeOpenError("invalid-path", "path is not a regular file under root");/if (!createdForWrite && (lstat.isSymbolicLink() || !lstat.isFile())) throw new SafeOpenError("invalid-path", "path is not a regular file under root");/' \
  /Users/{USERNAME}/.nvm/versions/node/{NODE_VERSION}/lib/node_modules/openclaw/dist/windows-spawn-oQqooioe.js

Patch 3 --- windows-spawn-oQqooioe.js:强制跳过 Python,走 Node.js fallback

arduino 复制代码
sed -i '' 's/const child = spawn("python3",/const { EventEmitter } = await import("node:events"); const child = Object.assign(new EventEmitter(), { stdin: null, stdout: Object.assign(new EventEmitter(), { setEncoding: ()=>{} }), stderr: Object.assign(new EventEmitter(), { setEncoding: ()=>{} }), kill: ()=>{} }); setTimeout(()=>child.emit("close", 0, null), 0); // patched\nif (false) spawn("python3",/' \
  /Users/{USERNAME}/.nvm/versions/node/{NODE_VERSION}/lib/node_modules/openclaw/dist/windows-spawn-oQqooioe.js

最终安装

ini 复制代码
# 清理残留配置(如有)
node -e "
const fs = require('fs');
const cfg = JSON.parse(fs.readFileSync(process.env.HOME + '/.openclaw/openclaw.json', 'utf8'));
cfg.plugins.allow = cfg.plugins.allow.filter(x => x !== 'openclaw-weixin');
delete cfg.plugins.entries['openclaw-weixin'];
delete cfg.plugins.installs['openclaw-weixin'];
fs.writeFileSync(process.env.HOME + '/.openclaw/openclaw.json', JSON.stringify(cfg, null, 2));
"

# 安装插件
openclaw plugins install "@tencent-weixin/openclaw-weixin"

# 扫码注册
npx -y @tencent-weixin/openclaw-weixin-cli@latest install

注意事项

  • OpenClaw 升级后 patch 会失效,需重新执行以上三个 patch
  • 这是 OpenClaw 的 bug,建议向官方反馈:macOS 上应优先检测平台是否支持 dir_fd,不支持时直接走 Node.js fallback
相关推荐
CDwenhuohuo13 分钟前
electron pc项目打包成桌面端
前端·javascript·electron
前端大斗师15 分钟前
「大于 1000」把 1000 元那单也算进去了:我在 Vue3 订单页对了 10 句话
前端·人工智能·typescript·大模型·原力计划
To_OC23 分钟前
被 Vibe Coding 反噬之后,我老老实实地回去写文档了
aigc·ai编程·vibecoding
Jmyd01231 小时前
用 Web VR 引擎搭建 3D 虚拟展厅:从素材上云到多端实时渲染的完整数据链路
前端·3d·vr·三维数字化
刘天远2 小时前
Agent成本核算实现:事件表、状态分布与Python归集
前端·数据库·人工智能·python
欣欣之王来了2 小时前
开发环境准备:Node.js、npm、VS Code安装配置
前端·学习·架构·项目·vue3教程
xiaolinudao1232 小时前
将多个 Excel 表格中的数据合并到单个表中|6 种实现方案全解析
java·前端·excel
李福春2 小时前
技术思考问题2:AI 编程高效的关键,是更强模型还是更清晰的问题定义?
ai编程·工程效能·vibe coding·深圳同盟·腾讯云架构师技术同盟·能力圈·检查清单
小虎AI生活3 小时前
AI 替掉重复劳动后,把人转向获客侧的实操方法(附提示词模板)
aigc·ai编程
LRL_3 小时前
跨平台 Node 模块安装指南:如何利用 pnpm/npm 配置`supportedArchitectures` 锁定平台依赖
前端·npm·node.js