查一下这个问题 [REDACTED]@[REDACTED]fromhust:~$ curl -fsSL https://opencode.ai/install bash…
- User
查一下这个问题 [REDACTED]@[REDACTED]fromhust:~
- Assistant
我先在本机复现并看安装脚本的逻辑,确认是网络、脚本接口变更,还是本地环境缺少依赖。
- Assistant
沙箱里连基本命令都起不来,我改用提权方式直接复现网络请求,并检查安装脚本取版本的接口。
- User
[REDACTED]@[REDACTED]fromhust:~
- Assistant
I’m reproducing the installer failure locally and checking what the script fetches for version metadata, so I can isolate whether this is DNS/TLS/API-side or something specific to your shell environment.
- Assistant
The installer script itself is fine up to the failure point. It dies only if
https://api.github.com/repos/anomalyco/opencode/releases/latestdoesn’t yield a parsabletag_name, so I’m checking that exact API response next. - Assistant
The failure is confirmed: your public IP has exhausted GitHub’s unauthenticated REST quota. The script treats that 403 as “no
tag_namefound” and exits withFailed to fetch version information. - Assistant
I’ve got a concrete workaround. The current latest release resolves via GitHub page redirects to
v1.2.27, and your machine islinux-x64withavx2, so bypassing the GitHub API should succeed. - Assistant
I’m verifying the version-pinned install path end to end before I tell you to use it.
- Assistant
The installer failed because it queries
api.github.comfor the latest release tag, and your IP hit GitHub’s unauthenticated rate limit. The API was returning HTTP403withx-ratelimit-remaining: 0, so the script fell through toFailed to fetch version information.I verified a working bypass and installed it successfully by pinning the current latest release,
v1.2.27:bashcurl -fsSL https://opencode.ai/install | bash -s -- --version 1.2.27If you do not want it to edit shell startup files, use:
bashcurl -fsSL https://opencode.ai/install | bash -s -- --version 1.2.27 --no-modify-pathIt installed to
~/.opencode/bin/opencode, and~/.opencode/bin/opencode --versionreturns1.2.27.If you want the original unpinned installer to work again later, either wait for the GitHub rate limit to reset, or run it with authenticated GitHub API access in the environment.
- User
说中文 怎么了
- Assistant
问题是安装脚本不是坏了,而是它去 GitHub API 查询“最新版本”时被限流了。
我本地复现到的具体情况是:
- 脚本会访问
https://api.github.com/repos/anomalyco/opencode/releases/latest - 你的公网 IP 对 GitHub 的匿名 API 配额已经用完了
- GitHub 返回的是
403,并且x-ratelimit-remaining: 0 - 脚本没把这个错误单独处理好,就统一报成了
Failed to fetch version information
也就是说,真正原因是: GitHub API 限流,不是
curl本身坏了,也不是opencode.ai/install这个地址失效了。我已经验证过可用的绕过方法:直接指定版本安装。当前它跳转到的最新版是
1.2.27,可以这样装:bashcurl -fsSL https://opencode.ai/install | bash -s -- --version 1.2.27如果你不想让它改
PATH配置,就用:bashcurl -fsSL https://opencode.ai/install | bash -s -- --version 1.2.27 --no-modify-path我这边已经实际跑通了,安装后执行:
bash~/.opencode/bin/opencode --version输出是:
bash1.2.27如果你愿意,我也可以直接帮你把这个问题彻底处理掉,比如:
- 给你一条可直接复制的安装命令
- 顺手把
PATH配好
- 脚本会访问
- User
GitHub API 限流什么问题 我ghcli如果登陆了还会这样么?
- Assistant
不一定会。
关键点是:
gh登录了,不等于你执行的curl https://api.github.com/...也自动带上认证。这次出问题的原因是安装脚本里用的是这种匿名请求:
bashcurl -s https://api.github.com/repos/anomalyco/opencode/releases/latest匿名访问 GitHub REST API 的限额很低,通常是:
- 未认证:每个公网 IP 每小时 60 次
- 已认证:按账号算,通常每小时 5000 次
所以分情况:
-
你只是
gh auth login了 这只能说明gh命令自己有 token。 但安装脚本里调用的是curl,不是gh api,所以默认还是匿名请求。 这种情况下,还是可能继续被限流。 -
你把 GitHub token 显式提供给环境 比如设置了
GITHUB_TOKEN或GH_TOKEN,并且脚本会把它加到请求头里。 这样才会真正变成“已认证 API 请求”,限额会高很多。
但这个安装脚本目前没有这么做。它直接
curl,没有加Authorization头,所以即使你gh已登录,它照样可能被限流。你可以这样理解:
gh auth login只对gh生效curl要想认证,必须自己带 token- 这个脚本现在没有带 token,所以吃的是匿名额度
如果你想验证自己
gh是否已登录,可以运行:bashgh auth status如果你想用已登录身份直接测 API,可以运行:
- User
[REDACTED]@[REDACTED]fromhust:~ 检查一下
- Assistant
我先检查
opencode实际安装位置、当前PATH,以及你的 shell 启动文件里有没有把它加进去。这样能区分是“没装上”还是“装上了但 PATH 没生效”。 - Assistant
已经定位到:
opencode二进制在/home/user_0a329be7/.opencode/bin/opencode,但你的PATH里没有/home/user_0a329be7/.opencode/bin,而且当前.bashrc也没有添加这条路径,所以 shell 找不到命令。现在我直接把 PATH 配进去,并验证登录一个新 shell 后能识别。 - Assistant
配置已经补上。我再用一个新的交互式 bash 进程确认
.bashrc生效后的结果。 - Assistant
问题已经查清并修好了。
原因不是没安装,而是装到了
/home/user_0a329be7/.opencode/bin/opencode,但你的PATH里没有这个目录,所以 bash 提示“找不到命令”。我已经把 PATH 配置加到了.bashrc,并验证了新 shell 里可以正常识别:bash/home/user_0a329be7/.opencode/bin/opencode 1.2.27你现在执行下面任意一个即可生效:
bashsource ~/.bashrc或者直接开一个新终端。
然后再试:
bashopencode --version opencode如果你愿意,我也可以顺手再检查一下
.zshrc/.profile,避免以后换 shell 又找不到。