Ubuntu 18.04 throws 404 error while fetching dependencies
I have four build servers that were all setup the same originally. We've been using them to cross-compile C projects. I'm trying to update them compile C++ natively as well. Two of the servers I was able to install g++ on with no problem, the other two though gave me 404 errors.
$ 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?
I have confirmed that all four report the same version info.
$ 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
Solution 1:
I run into this issue almost every time I set up a new box.
Run sudo apt update
before you install the packages.
Solution 2:
Set your system time to the correct time of your time zone and then
try sudo apt update
before running
your command sudo apt-get install g++