127

I'm trying to install ROS on Ubuntu. I'm getting this error:

   sudo apt-get update
Hit:1 http://pk.archive.ubuntu.com/ubuntu cosmic InRelease
    Hit:2 http://pk.archive.ubuntu.com/ubuntu cosmic-updates InRelease
    Hit:3 http://pk.archive.ubuntu.com/ubuntu cosmic-backports InRelease
    Get:4 http://security.ubuntu.com/ubuntu cosmic-security InRelease [83.2 kB]
    Ign:5 http://packages.ros.org/ros/ubuntu cosmic InRelease Err:6 http://packages.ros.org/ros/ubuntu cosmic Release 404 Not Found [IP: 64.50.236.52 80] Reading package lists... Done
    E: The repository 'http://packages.ros.org/ros/ubuntu cosmic Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Suleman Khan
  • 1,297
  • 2
  • 7
  • 3

11 Answers11

93

You need to update your repository targets to the Focal Fossa (20.04) release of Ubuntu. This can be done like so:

sudo sed -i -e 's|disco|focal|g' /etc/apt/sources.list
sudo apt update
Shai
  • 25,159
  • 9
  • 44
  • 67
Bhupesh Parakh
  • 1,075
  • 6
  • 9
74

As described here, you need to edit (as root) the file /etc/apt/sources.list (the easiest way to do this is to type sudo gedit /etc/apt/sources.list). On the line that mentions http://packages.ros.org/ros/ubuntu you need to add [trusted=yes] after the word deb (you might need to add it as a separate word). Then save the file and try again.

Robin Green
  • 32,079
  • 16
  • 104
  • 187
  • i am facing same issue with 'http://ppa.launchpad.net/gencfsm/ppa/ubuntu' ; i am on ubuntu eoan 19.10 but when I search for the ppa on >>sources.list it doesn't have it. pls help – Awakened Feb 14 '20 at 09:19
  • 14
    It might be in a file in `/etc/apt/sources.list.d`. Look in that directory. – Robin Green Feb 14 '20 at 17:47
  • 1
    what if this happens with your CI build agent? – knocte Apr 16 '20 at 11:52
  • @knocte if you are managing to run sudo commands on your CI agent, I don't see the problem - you can do anything. Anyway, that question isn't really specific to this question. – Robin Green Apr 16 '20 at 19:59
  • what I mean is that it's really hard to **edit** a file with commands, unless you start doing some *sed* juggling and whatnot; I wonder how to fix this problem easily – knocte Apr 18 '20 at 12:42
  • @knocte if you have a file with the wrong configuration in /etc/apt/sources.list.d *on your CI agent*, then someone has set up your CI agent incorrectly, or (but this is less likely) your OS distribution has shipped an incorrect config file. Fix that problem, ideally. – Robin Green Apr 27 '23 at 08:36
64

#For Unable to 'apt update' my Ubuntu 19.04

The repositories for older releases that are not supported (like 11.04, 11.10 and 13.04) get moved to an archive server. There are repositories available at http://old-releases.ubuntu.com.

first break up this file

cp  /etc/apt/sources.list /etc/apt/sources.list.bak
sudo sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

then

sudo apt-get update && sudo apt-get dist-upgrade
fguillen
  • 36,125
  • 23
  • 149
  • 210
Sagar Jethi
  • 2,313
  • 20
  • 20
  • 5
    This helped me, thank you! I'd still recommend to create a backup before running the sed though: `sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak` – kuropan Dec 19 '20 at 15:08
  • I have no idea what I am doing but this helped on 21.04 after a while of not using my Ubuntu, cheerios. – Jacek Góraj Sep 14 '22 at 18:48
13

Make sure your /etc/apt/sources.list has http://old-releases.ubuntu.com instead of in.archive

Attila Szeremi
  • 5,235
  • 5
  • 40
  • 64
srujan kumar
  • 171
  • 1
  • 7
13

I opened up my Software & Updates program and switched from my country to the main servers like so:
Software & Updates screen

After I done this and run the sudo apt update commando again, my problems where gone.

SteZZz
  • 151
  • 1
  • 4
  • On mine, this lead to a message about an internal error, with a prompt to send details to developers, and it got stuck once I pressed send. I didn't record exactly what package was the issue, but gtk was included in the name. I don't have time for now to record more details. I will leave it for now but if this comment gets votes then between all of us we can look into it further. – pateksan May 17 '20 at 11:51
7

In my case the cause was Ubuntu version no longer supported by Canonical. I was able to upgrade to still supported LTS with 2 steps:

1) Manually update repo links from "in.ubuntu" to "old-releases.ubuntu". 1.1) Installed all outstanding updates 2) do-release-upgrade was able to take from this point and do actual upgrade

IMHO, this is safer method then just updating repositories to next supported ubuntu, since do-release-upgrade have chance to prevent upgrade that could fail, and may be able to diagnose a problem for you.

pateksan
  • 160
  • 1
  • 12
przemo_li
  • 3,932
  • 4
  • 35
  • 60
4

im use this code to and suggest you:

1) sudo sed -i -e 's|disco|eoan|g' /etc/apt/sources.list
2) sudo apt update
Milad Tazikeh
  • 65
  • 1
  • 3
4

If a sudo apt-get update did not do it for you, it might be that some packages have failed to updated to repository-related errors.

For me all of those happened to reside in (Software Updates --> Other Software). You could remove them with "Remove", the cache will be refreshed successfully. Otherwise

sudo apt-get clean
apt-get autoremove 

is something to try.

rtviii
  • 807
  • 8
  • 19
1

I have been having this issue for a couple of weeks and finally decided to sit down and try and fix it. I have no interest in config file editing as I'm primarily a Windows user.

In a fit of "clickyness" I noticed that the ubuntu server location was set "for United kingdom". I switched this over to "Main Server" and hey presto... it all stared updating.

So, it seems like the regionalised server (for the UK at least) has a very limited support window so if you are an infrequent user it is likely it will not have a valid upgrade path from your current version to the latest.

Edit: I only just noticted the previous reply, after posting. 100% agree.

Paul Eden
  • 338
  • 1
  • 3
  • 10
0

If You are facing an issue with a new "EC2 Instance" or "Ubuntu instance"

Then first do this sudo apt-get upgrade and then try again to install any thing in same way as mentioned in documentation.

rohitcoder
  • 401
  • 1
  • 7
  • 18
-3

This problem is probably from your /etc/apt/sources.list as others mentioned but there is chance that the problem is with your hard disk. I solved the same issue by cleaning up some space.

When you don't have enough space on your hard disk, updating your machine won't occur until you delete some files.

AmirH.
  • 63
  • 6
  • A 404 error is never a disk space related issue. It's that the request is being sent to a place that doesn't exists. – rm- Mar 11 '20 at 10:35
  • I had the exact same issue in Ubuntu with the exact same error on the screen. As I mentioned the problem is likely for sources.list file but if it wasn't the issue, check your hard disk as well. @rm- – AmirH. May 09 '20 at 06:11