“ Repository 没有发布文件”错误

我正在尝试在 Ubuntu 上安装 ROS,我得到了这个错误:

   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.
294145 次浏览

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.

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

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.

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.

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

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.

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.

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

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.

#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

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.