![Ubuntu 18.04 在获取依赖项时抛出 404 错误](https://linux22.com/image/1013969/Ubuntu%2018.04%20%E5%9C%A8%E8%8E%B7%E5%8F%96%E4%BE%9D%E8%B5%96%E9%A1%B9%E6%97%B6%E6%8A%9B%E5%87%BA%20404%20%E9%94%99%E8%AF%AF.png)
我有四台构建服务器,它们最初都是以相同的方式设置的。我们一直使用它们来交叉编译 C 项目。我正在尝试更新它们,以便它们也能本地编译 C++。其中两台服务器我可以毫无问题地安装 g++,但另外两台却出现了 404 错误。
$ sudo apt-get install g++
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
g++-7 libstdc++-7-dev
Suggested packages:
g++-multilib g++-7-multilib gcc-7-doc libstdc++6-7-dbg libstdc++-7-doc
The following NEW packages will be installed:
g++ g++-7 libstdc++-7-dev
0 upgraded, 3 newly installed, 0 to remove and 5 not upgraded.
Need to get 9,043 kB of archives.
After this operation, 40.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Err:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libstdc++-7-dev amd64 7.4.0-1ubuntu1~18.04
404 Not Found [IP: 91.189.88.149 80]
Err:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 g++-7 amd64 7.4.0-1ubuntu1~18.04
404 Not Found [IP: 91.189.88.149 80]
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 g++ amd64 4:7.4.0-1ubuntu2.2
404 Not Found [IP: 91.189.88.149 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-7/libstdc++-7-dev_7.4.0-1ubuntu1~18.04_amd64.deb 404 Not Found [IP: 91.189.88.149 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-7/g++-7_7.4.0-1ubuntu1~18.04_amd64.deb 404 Not Found [IP: 91.189.88.149 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-defaults/g++_7.4.0-1ubuntu2.2_amd64.deb 404 Not Found [IP: 91.189.88.149 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
我已经确认所有四个都报告了相同的版本信息。
$ uname -a
Linux build_server4 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
答案1
我几乎每次设置新盒子时都会遇到这个问题。
sudo apt update
在安装软件包之前运行。
答案2
如果从 docker 运行,并且已经apt-get update
在 Dockerfile 中,请尝试使用--no-cache
或使用缓存破坏。
答案3
将系统时间设置为您所在时区的正确时间,然后sudo apt update
在运行命令之前尝试sudo apt-get install g++
答案4
就我而言,将 ubuntu-esm-infra 的源(位于 /etc/apt/sources.list.d/ubuntu-esm-infra.list)从 xenial 更改为 bionic 导致了 404 或 401 错误。
由于此源的软件包对于运行 Ubuntu 并非必不可少(也许 Canonical 有不同的看法),我在 do-release-upgrade 之前停用了这些源。
运行标准后
apt-get update && apt-get upgrade
没有出现更多错误。