33

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
2
  • 1
    Are you, by chance, using a school, corporate, or other network? Those often require proxies or IT dept permission.
    – user535733
    Jul 18, 2019 at 0:23
  • corporate network, but we don't have any restrictions. I tried opening the paths that give a 404 in a web browser and got the same error. One level up though works, and I don't see the packages it's trying to download in the list. I think apt is generating the wrong package names somehow.
    – Conlan
    Jul 18, 2019 at 0:41

6 Answers 6

70

I run into this issue almost every time I set up a new box.

Run sudo apt update before you install the packages.

2
  • 2
    Had the same problem but while building a docker container. i realised that the apt update potion was using the docker cache which was out of date so I just used "no-cache" and all worked. Apr 4, 2020 at 9:45
  • sudo apt upgrade .....Helped me
    – yunus
    Jul 24, 2020 at 4:21
7

If running from docker and you already have apt-get update in your Dockerfile try running with --no-cache or use cache busting.

4

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++

2

for me I solved the issue by fixing the time zone difference

  1. I correct the time zone
  2. sudo apt clean
  3. sudo apt autoclean
  4. sudo apt update

that works just fine.

0

In my case, changing the sources of ubuntu-esm-infra (located in /etc/apt/sources.list.d/ubuntu-esm-infra.list) from xenial to bionic resulted in 404 or 401 errors.

As packages of this source are not essential for running Ubuntu (mybe Canonical thinks differently), I deactivated these sources before do-release-upgrade.

after running the standard

apt-get update && apt-get upgrade

no more errors showed up.

-2

I have replaced source.list with below text, resolved my issue.

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise main
deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise main


## Major bug fix updates produced after the final release of the
## distribution.
deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates main
deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates main


## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise universe
deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates universe


## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
# deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise multiverse
# deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise multiverse
# deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates multiverse
# deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-updates multiverse


## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
# deb-src http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse


## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu precise partner
# deb-src http://archive.canonical.com/ubuntu precise partner


deb http://security.ubuntu.com/ubuntu precise-security main
deb-src http://security.ubuntu.com/ubuntu precise-security main
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
# deb http://security.ubuntu.com/ubuntu precise-security multiverse
# deb-src http://security.ubuntu.com/ubuntu precise-security multiverse

after that run this

sudo apt update

in your terminal

1
  • 2
    The sources.list, you have posted, seems to be for 12.04 Precise Pangolin and it's a bad idea to use repositories from other releases. Did you really have 12.04 installed? Well, that release reached end of public support way back in 2017. I'm not sure about March but in July 2021, precise folder ain't available in security.ubuntu.com/ubuntu/dists. So, this would essentially lead to more 404s.
    – Kulfy
    Jul 15, 2021 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.