元数据
| id | apt-404-broken | 收录 | 2026-08-29 |
|---|---|---|---|
| 问题域 | 编码代理与终端 | 主题分组 | 网络与镜像 |
| 适用工具 | apt · 外部工具 | ||
症状
`apt-get update` / `apt-get install` 报源失效:
```
Err:2 https://deb.debian.org/debian nonexistent-suite Release
404 Not Found [IP: 151.101.90.132 443]
E: The repository 'https://deb.debian.org/debian nonexistent-suite Release' does not have a Release file.
```
特征:update 阶段出现 `Err:N ... 404 Not Found`(或 `File not found`)并最终 `E: The repository ... does not have a Release file`;
apt-get 退出码 100;常见于:第三方自定义 deb 源下线/路径变了、PPA 停更(launchpad 上老 PPA 被清理)、镜像站过期/组件名拼错、
Ubuntu 旧版本官方源退役(如 12.10 时代的 `archive.ubuntu.com` 老路径)、`/etc/apt/sources.list.d/` 里有残留的坏条目。
原因
apt 的源(sources.list / sources.list.d/*.sources)指向的仓库不再能提供 `dists/<suite>/Release` 文件时,就会报 404 + 无 Release 文件。
可能原因:
- 源地址本身失效(项目不再维护 deb 仓库、域名过期、路径变更);
- suite 名称拼错或不存在(如把 `bookworm` 写成 `bookworm2`,或指向尚未发布/已归档的 suite);
- 源来自旧教程,发布后仓库被删("照教程配源"最常见的中招场景);
- 镜像站只同步了部分组件(`main` 有、`universe` 缺失),或拉取时网络中断留下半成品。
注意:`apt-get update` 是"取清单"阶段,任何一个源失败都会让整个命令退出 100,即使其它源正常。
解法
1. **先定位是哪个源挂了**:完整看 update 输出里的 `Err:` 行(仓库 URL + suite),再 `grep -r "^deb" /etc/apt/sources.list /etc/apt/sources.list.d/`(deb822 格式看 `Types:/URIs:/Suites:` 行)核对条目。
2. **验证源是否真实可访问**:`curl -sI <URIs>/dists/<suite>/Release` —— 返回 200 说明源没问题,404 说明条目已失效。
3. **删除或注释坏条目**:把失效的 .list/.sources 移出目录(`rm /etc/apt/sources.list.d/bad.list`)或注释掉,重新 `apt-get update`。
4. **换有效源**:Ubuntu 官方源 `http://archive.ubuntu.com/ubuntu/`(Debian 用 `https://deb.debian.org/debian/`),
国内可换清华/阿里云镜像(路径结构相同,suite 名不变);不要用"老教程里的源"——先 curl 验证再写入。
5. **PPA 停更场景**:`add-apt-repository` 过的老 PPA 被 launchpad 清理后 404,直接删对应 `/etc/apt/sources.list.d/<ppa>.list` 即可。
6. **版本太旧场景**:发行版 EOL 后官方源退役(404),需升级发行版或改用 `old-releases.ubuntu.com`(仅建议临时用)。
验证证据
- 本地实测(2026-08-29,WSL Ubuntu,apt 2.x,用 `-o Dir::Etc::sourcelist=...` 隔离临时源,未触碰系统配置):
- 坏源①:`deb https://deb.debian.org/debian/ nonexistent-suite main` → update 报 `Err:2 ... nonexistent-suite Release 404 Not Found`,
`E: does not have a Release file`,apt-exit=100;
- 坏源②:本地 404 服务器(`python3 -m http.server` 只返回 404)→ 同样报 `Err: ... 404 File not found` + exit 100,
与真实"镜像过期/源失效"完全同款——本地可稳定复现;
- 修复链路:换成宿主机有效镜像(`archive.ubuntu.com` + 正确 suite)→ update 正常,apt-exit=0。
- 参考案例:[1BAH/fenrir#10](https://github.com/1BAH/fenrir/issues/10)(自定义 deb 源 404 装不上)、[amandeepg/notifyosdconfig#1](https://github.com/amandeepg/notifyosdconfig/issues/1)(老 PPA 404)同款现象。
- 实测复现日志(2026-08-29)
来源与证据
素材来源:https://github.com/1BAH/fenrir/issues/10
验证证据:Evidence details kept locally (2026-08-29)