Claude Desktop on Ivy Bridge Mac:用 Node.js Wrapper 繞過 AVX2 限制
此為深度內容 — 這篇文章深度分析 AVX2 限制,探討 Mac 上 Claude Desktop 解法
需要登入才能閱讀完整文章。
適用機型:2012 年(含)以前出廠的 Intel Mac(Ivy Bridge 架構,i7-3xxx / i5-3xxx 系列)。這些 CPU 不支援 AVX2 指令集,而 Claude Desktop 內建的 Claude Code binary 要求 AVX2,執行後立即 SIGILL(exit code 132)。
上一篇文章(Claude Code v2.1.113 讓 Intel Mac 整個掛掉)處理的是 npm CLI 的問題,解法是降版到 v2.1.112 並鎖死。但如果你想在 Claude Desktop 介面內使用 Claude Code,降版 npm 套件是沒用的——Claude Desktop 有自己的 binary,跟 npm 完全獨立。
Claude Desktop 不用你的 npm
這是整件事最容易混淆的地方。
Claude Desktop 在內部維護一套自己的 Claude Code binary,路徑在:
~/Library/Application Support/Claude/claude-code/<版本>/claude.app/Contents/MacOS/claude
啟動時會從 log 看到:
Using Claude Code binary: ~/Library/Application Support/Claude/claude-code/2.1.111/...
這個 binary 是 Claude Desktop 在背景自動下載的,與 npm 的 @anthropic-ai/claude-code 套件毫無關係。即使你用 npm 降版到 v2.1.112,Claude Desktop 還是會呼叫它自己那份 native binary,然後一樣 SIGILL。
解法:Node.js Wrapper
思路很簡單:把 Claude Desktop 內建的 binary 換成一個 bash script,讓這個 script 去呼叫 npm 安裝的 Node.js 版 CLI(沒有 AVX2 問題)。
步驟一:確認 binary 路徑
grep "Using Claude Code binary" ~/Library/Logs/Claude/main.log | tail -3
記下版本號,例如 2.1.111。
步驟二:解鎖目錄
如果之前有鎖定(或預防性先解鎖):
chflags -R nouchg ~/Library/Application\ Support/Claude/claude-code/
步驟三:備份並替換 binary
BINARY=~/Library/Application\ Support/Claude/claude-code/2.1.111/claude.app/Contents/MacOS/claude
mv "$BINARY" "${BINARY}.orig"
cat > "$BINARY" << 'WRAPPER'
#!/bin/bash
exec /Users/your-name/.local/share/fnm/node-versions/v22.16.0/installation/bin/node \
/Users/your-name/.local/share/fnm/node-versions/v22.16.0/installation/lib/node_modules/@anthropic-ai/claude-code/cli.js "$@"
WRAPPER
chmod +x "$BINARY"
注意:/Users/your-name 和 Node 版本號請換成你自己的路徑。用 which node 找到 node 真實路徑(不是 symlink)。
步驟四:鎖定,防止被覆蓋
chflags -R uchg ~/Library/Application\ Support/Claude/claude-code/
完成後重新開 Claude Desktop,Claude Code 應該可以正常執行。
為什麼必須用絕對路徑
Claude Desktop 啟動環境沒有 PATH。如果 wrapper 寫 exec node ... 或 exec $(which node) ...,Claude Desktop 執行時找不到 node,得到 exit code 127(command not found)。
必須完整寫出 node binary 和 cli.js 的絕對路徑。用 fnm 管理 Node 的話,路徑通常在:
~/.local/share/fnm/node-versions/v22.16.0/installation/bin/node
用 nvm 的話在:
~/.nvm/versions/node/v22.16.0/bin/node
Homebrew 安裝的 node 在:
/opt/homebrew/bin/node # Apple Silicon
/usr/local/bin/node # Intel,但 Intel Mac 用 Homebrew 比較少見
防止 Claude Desktop 自動更新
Claude Desktop 更新後可能下載新版 claude-code binary(新目錄名),舊目錄的 wrapper 就沒用了。同時鎖定整個 app bundle 可以防止 Squirrel updater 自動更新:
# 鎖定 app bundle
chflags -R uchg /Applications/Claude.app
# 鎖定 claude-code 目錄(上面步驟四已做)
chflags -R uchg ~/Library/Application\ Support/Claude/claude-code/
如果真的要更新,先解鎖,更新完再重複 wrapper 流程,然後重新鎖定:
chflags -R nouchg /Applications/Claude.app
chflags -R nouchg ~/Library/Application\ Support/Claude/claude-code/
取得特定版本的 Claude Desktop
如果需要安裝特定版本(例如 AVX2 問題出現前的版本),可以從 Homebrew Cask 的歷史 commit 取得下載 URL:
# 查 Homebrew Cask 的歷史 commit
curl -s "https://api.github.com/repos/Homebrew/homebrew-cask/commits?path=Casks/c/claude.rb&per_page=50" | \
python3 -c "import sys,json; [print(c['commit']['committer']['date'][:10], c['commit']['message'].split('\n')[0]) for c in json.load(sys.stdin)]"
# 取得特定版本的 .rb 內容(把 <commit_sha> 換成對應 commit)
curl -s "https://api.github.com/repos/Homebrew/homebrew-cask/contents/Casks/c/claude.rb?ref=<commit_sha>" | \
python3 -c "import sys,json,base64; print(base64.b64decode(json.load(sys.stdin)['content']).decode())"
下載 URL 格式:
https://downloads.claude.ai/releases/darwin/universal/<版本>/Claude-<sha>.zip
更新後 exit code 132 又出現
Claude Desktop 版本升級後,它可能下載新的 claude-code binary(新目錄),wrapper 就失效了。處理方式:
- 查 log 確認新路徑:
grep "Using Claude Code binary" ~/Library/Logs/Claude/main.log | tail -3
- 解鎖:
chflags -R nouchg ~/Library/Application\ Support/Claude/claude-code/
對新版本目錄重複步驟三(備份 + 建 wrapper + chmod)
重新鎖定:
chflags -R uchg ~/Library/Application\ Support/Claude/claude-code/
關於 VM 功能(remote control)
Claude Desktop 有一個 VM 功能,會在背景下載 rootfs.img(約 2GB+)。這個功能在 Ivy Bridge 上無法使用,而且會佔用大量磁碟空間。可以清空並鎖定:
rm -rf ~/Library/Application\ Support/Claude/vm_bundles/*
chflags uchg ~/Library/Application\ Support/Claude/vm_bundles/
鎖定後 Claude Desktop 就不會再重新下載了。
上述方法可以讓 Ivy Bridge Mac 在 Claude Desktop 內正常使用 Claude Code,同時對 npm CLI 的影響參見前一篇文章的降版解法。
想看更多作品、服務與主站整理,請前往 stanwu.org。