如何修复 add-apt-repository: command not found

问题

在 Ubuntu 或 Debian 上尝试添加 PPA 仓库时,你可能会遇到以下错误:

terminal-output.txt
$ sudo add-apt-repository ppa:some/ppa
sudo: add-apt-repository: command not found

解决方案

add-apt-repository 命令属于 software-properties-common 软件包。要安装它,请运行以下命令:

install-software-properties.sh
sudo apt-get update
sudo apt-get install software-properties-common

之后,你应该就能正常使用 add-apt-repository 命令了。

如果你看到如下错误信息

terminal-output.txt
E: Unable to locate package software-properties-common

那么你可能正在使用 Debian Trixie。对于 Debian Trixie,我不知道使用 add-apt-repository 的直接方法。由于 PPA 是为 Ubuntu 设计的,你可以寻找替代的仓库,或者考虑升级到更新版本的 Debian,又或者如果确实需要 PPA 支持,则改用 Ubuntu。


Check out similar posts by category: Linux