主题
install.sh 下载失败 / 显示 ✅ 但找不到 claude
现象
bash
$ curl -fsSL https://claude.ai/install.sh | bash
Setting up Claude Code...
✅ Installation complete!
$ claude
claude: command not found
$ find ~ -name claude -type f
# 空结果 — 二进制根本没装上脚本打了 ✅ 但完全没装上。
真因
https://claude.ai/install.sh 在某些网络环境会被重定向到一个 HTML 错误页(标题 "App unavailable in region"),bash 把 HTML 当脚本跑,大部分 HTML 标签报错被吞,碰巧让两行 echo 显示成功的字样。
可以自己验证:
bash
curl -fsSL https://claude.ai/install.sh | head -3
# 看到 <!DOCTYPE html> 或 <title>App unavailable...</title> 就是这个问题解决方案(任选其一)
方案 1:用 npm 安装(推荐 ⭐)
绕过 claude.ai 的 CDN,用 npm registry 直接装:
bash
# 安装 nodejs(如果没有)
sudo apt update && sudo apt install -y nodejs npm # Debian/Ubuntu
brew install node # macOS
# 如果 nodejs 版本 < 18,换 NodeSource 装新版
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# 用户级 npm 目录避免权限问题
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
# 装 claude(如果慢,加镜像源:--registry=https://registry.npmmirror.com)
npm install -g @anthropic-ai/claude-code
# 加 PATH
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc
exec $SHELL
# fish 用户
fish_add_path ~/.npm-global/bin
# 验证
claude --version方案 2:手动从 GitHub Releases 下载
bash
# 找对应平台的 release
# https://github.com/anthropics/claude-code/releases
# 例:Linux arm64
curl -fsSL -o claude \
https://github.com/anthropics/claude-code/releases/latest/download/claude-linux-arm64
chmod +x claude
mkdir -p ~/.local/bin
mv claude ~/.local/bin/
export PATH="$HOME/.local/bin:$PATH"
claude --version方案 3:用本地代理出网装
如果你的机器本地有可用的网络代理:
bash
# 设环境变量后再装
export https_proxy=http://127.0.0.1:你的端口
export http_proxy=http://127.0.0.1:你的端口
curl -fsSL https://claude.ai/install.sh | bash装完一次后实际使用不需要代理(你连的是 Shuro 不是 claude.ai 的 CDN)。
验证装好了
不要只看 Installation complete! 字样,实际 ls 一下:
bash
# 找 claude 二进制(应该有结果)
find ~ -name claude -type f 2>/dev/null
# 验证版本(应该有输出)
claude --version
# 如果第二步报 command not found,加 PATH 再试
export PATH="$HOME/.local/bin:$HOME/.npm-global/bin:$PATH"
claude --versionCodex CLI 也有类似问题吗
| 工具 | 安装路径 | 是否有此问题 |
|---|---|---|
Claude Code (claude.ai/install.sh) | 自定义 CDN | ⚠️ 偶尔 |
Codex CLI (npm install -g @openai/codex) | npm registry | ✅ 一般无 |
如果遇到 npm 慢,换镜像:
bash
npm config set registry https://registry.npmmirror.com装好之后用 Shuro 还需要特殊设置吗
不需要。只在安装阶段可能踩这个坑(要从特定 CDN 拉二进制)。
装好后客户端只连 Shuro,不再访问 claude.ai 的 CDN。(TODO/VERIFY:Shuro 的网络接入方式 / 国内是否可直连尚未确认,如访问不稳定见 代理设置。)
