如何修复 apt-get source You must put some 'source' URIs in your sources.list

问题:

你想使用以下命令下载 apt 源包

apt_get_source_example.sh
apt-get source <package name>

但你看到此错误消息:

apt_source_error.txt
E: You must put some 'source' URIs in your sources.list

解决方案

在大多数情况下,你可以使用以下命令轻松修复

apt_get_update.sh
sudo apt-get update

如果这没有解决问题,编辑 /etc/apt/sources.list,例如使用

edit_sources_list.sh
sudo nano /etc/apt/sources.list

并确保 deb-src 行未被注释掉。

示例:你需要将

sources_list_commented.txt
deb http://archive.ubuntu.com/ubuntu artful main restricted
# deb-src http://archive.ubuntu.com/ubuntu artful main restricted

改为

sources_list_uncommented.txt
deb http://archive.ubuntu.com/ubuntu artful main restricted
deb-src http://archive.ubuntu.com/ubuntu artful main restricted

并在更改文件后运行 sudo apt update

If there are reposi改为ries without a deb-src line, you can often try 改为 copy the deb line - for example, from

deb_repo_example.sh
deb http://myserver.com/deb focal main

你可以创建一个额外的行

deb_src_repo_example.txt
deb-src http://myserver.com/deb focal main

by changing deb 改为 deb-src and running sudo apt update afterwards. This often works, but it depends on the reposi改为ry.


Check out similar posts by category: Linux