Add update instructions and macOS task_for_pid troubleshooting to READMEs

This commit is contained in:
canghe
2026-04-04 14:46:12 +08:00
parent 6b36f92df6
commit ab890dfac0
2 changed files with 68 additions and 0 deletions

View File

@@ -39,6 +39,12 @@ npm install -g @canghe_ai/wechat-cli
> Currently ships a **macOS arm64** binary. Other platforms can use the pip method below. PRs with additional platform binaries are welcome.
**Update to the latest version:**
```bash
npm update -g @canghe_ai/wechat-cli
```
### pip
```bash
@@ -103,6 +109,35 @@ If you're unsure which WeChat account is currently active, navigate to the data
![init-claude-code-4](image/init-claude-code-4.png)
#### macOS: `task_for_pid failed` Error
On some macOS systems, `init` may fail with `task_for_pid failed` even when running with `sudo`. This is due to macOS security restrictions on process memory access.
**WeChat CLI will automatically attempt to fix this** by re-signing WeChat with the required entitlement. Just follow the on-screen instructions:
1. The tool will re-sign WeChat automatically
2. Quit WeChat completely (not just minimize)
3. Reopen WeChat and log in
4. Run `sudo wechat-cli init` again
If auto re-signing fails, you can do it manually:
```bash
# Quit WeChat first, then:
sudo codesign --force --sign - --entitlements /dev/stdin /Applications/WeChat.app <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>
EOF
```
> Note: If WeChat auto-updates, you may need to re-sign it again.
### Step 2 — Use It
```bash

View File

@@ -39,6 +39,12 @@ npm install -g @canghe_ai/wechat-cli
> 目前提供 **macOS arm64** 二进制。其他平台可使用下方 pip 安装。欢迎提交其他平台二进制 PR。
**更新到最新版本:**
```bash
npm update -g @canghe_ai/wechat-cli
```
### pip
```bash
@@ -101,7 +107,34 @@ wechat-cli init
![init-claude-code-4](image/init-claude-code-4.png)
#### macOS 遇到 `task_for_pid failed` 错误?
在某些 macOS 系统上,即使使用了 `sudo``init` 也可能报 `task_for_pid failed`。这是 macOS 的安全策略限制了进程内存访问。
**WeChat CLI 会自动尝试修复此问题**——对微信重新签名以获取必要权限。按提示操作即可:
1. 工具会自动对微信重新签名
2. 完全退出微信(不是最小化)
3. 重新打开微信并登录
4. 再次执行 `sudo wechat-cli init`
如果自动签名失败,可以手动执行:
```bash
# 先退出微信,然后:
sudo codesign --force --sign - --entitlements /dev/stdin /Applications/WeChat.app <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>
EOF
```
> 注意:如果微信自动更新了,可能需要重新执行签名。
### 第二步 — 开始使用