我无法将 ondrej 添加到我的 Ubuntu 20.04 安装中。
sudo 添加 apt-repository ppa:ondrej/php
上述命令返回以下错误
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 363, in <module>
addaptrepo = AddAptRepository()
File "/usr/bin/add-apt-repository", line 41, in __init__
self.distro.get_sources(self.sourceslist)
File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 91, in get_sources
raise NoDistroTemplateException(
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Ubuntu/focal
以下是 LSB 发布信息。
Distributor ID: Ubuntu
Description:Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
我做错什么了吗?
最终目标:我希望能够从 apt 安装 PHP 8.1 扩展
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"
apt-cache policy -> https://pastebin.com/84HauP14
aptitude search ~o -> https://pastebin.com/VhaW9qWq
namei /etc/os-release -> https://pastebin.com/XwjZHkKa
cat /etc/os-release -> https://pastebin.com/CywsZvEh
答案1
我无法使add-apt-repository
命令正常工作,因此我使用以下命令手动添加了存储库和签名密钥:
使用文本编辑器打开该
sources.list
文件(例如nano
):sudo nano /etc/apt/sources.list
在文件中添加以下行:
deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu focal main #deb-src https://ppa.launchpadcontent.net/ondrej/php/ubuntu focal main
添加存储库签名密钥:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4f4ea0aae5267a6c
答案2
我用这个命令解决了:
sudo apt-get install software-properties-common
正如 cloclw0rk 所写:
add-apt-repository 是 software-properties-common apt 包的一部分,因此您需要先安装它。-> 添加存储库时将自动导入密钥 – clockw0rk
答案3
我用这个命令解决了:
sudo apt-get install --reinstall libpython3-stdlib libpython3.8-minimal libpython3.8-stdlib python-apt-common python3 python3-apt python3-certifi python3-chardet python3-dbus python3-distro-info python3-gi python3-idna python3-minimal python3-pkg-resources python3-requests python3-requests-unixsocket python3-six python3-software-properties python3-urllib3 python3.8 python3.8-minimal software-properties-common
然后尝试添加新的存储库