在某些情況下,在 Linux Mint、Linux Lite、Zorin OS、elementary OS 和其他基於 Ubuntu 的發行版以及 Ubuntu 和 Debian 上,您會看到缺少 add-apt-repository 命令的錯誤。
$ sudo: add-apt-repository: command not found
本教程將向您展示如何快速修復 Debian、Ubuntu 和其他基於 Debian 的 Linux 發行版上的“add-apt-repository command not found”錯誤。
什麼是個人包裹存檔
PPA 是個人存儲庫的 Web URL。 存儲庫是一組文件,其中包含有關各種軟件、它們的版本以及校驗和等其他一些詳細信息的信息。 每個 Ubuntu 版本都有自己的官方四個存儲庫。
在 Ubuntu 或 Debian 上安裝軟件的最常見方法(如果軟件包不在官方存儲庫中)是使用 PPA(個人軟件包存檔)。
add-apt-repository 是一個命令行實用程序,用於在 Ubuntu 和 Debian Linux 中添加 PPA(個人包存檔)。
在 Ubuntu 中添加新的 PPA(個人包存檔)
如果要添加新的 PPA 存儲庫,則必須使用 add-apt-repository 命令:
sudo add-apt-repository ppa:some/ppa
例如:
sudo add-apt-repository ppa:dr-akulavich/lighttable
sudo apt-get update
sudo apt-get install lighttable-installer
如果您看到命令丟失的錯誤,您必須首先安裝包含 add-apt-repository 實用程序的包。
修復 add-apt-repository: command not found 錯誤
因此,較新系統上的 add-apt-repository 命令位於軟件包 software-properties-common 下,您需要先安裝該軟件包才能安裝 add-apt-repository。
在 Debian/Ubuntu LTS 上安裝軟件包
如果您使用的是 Debian / Ubuntu LTS 如 18.04、16.04 和 14.04 系統,則安裝 software-properties-common 包以獲取 add-apt-repository 命令。
$ sudo apt-get install -y software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
software-properties-common
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 9384 B of archives.
After this operation, 188 kB of additional disk space will be used.
Get:1 https://archive.ubuntu.com/ubuntu/ trusty-updates/main software-properties-common all 0.92.37.8 [9384 B]
Fetched 9384 B in 0s (47.0 kB/s)
Selecting previously unselected package software-properties-common.
(Reading database ... 62966 files and directories currently installed.)
Preparing to unpack .../software-properties-common_0.92.37.8_all.deb ...
Unpacking software-properties-common (0.92.37.8) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up software-properties-common (0.92.37.8) ...
注意:如果您看到一條錯誤消息,提示找不到 software-properties-common package,您應該運行 sudo apt-get update 然後嘗試重新安裝。
在 Ubuntu 13.10 及更早版本上安裝軟件包
如果您使用的是 Ubuntu v13.10 或更早版本,則可以在 python-software-properties 包下使用 add-apt-repository 命令。 因此,請使用 apt-get 命令安裝該軟件包。
$ sudo apt-get install -y python-software-properties
根據您的系統安裝了 software-properties-common 或 python-software-properties 後,您現在可以輕鬆地使用 add-apt-repository 或 apt-add-repository 命令來添加 PPA。
讓我們嘗試添加 example 本教程之前提到的 PPA:
$ sudo add-apt-repository ppa:dr-akulavich/lighttable
Light Table Installer: the package in this PPA downloads and installs the latest builds from https://lighttable.com/
More info: https://launchpad.net/~dr-akulavich/+archive/ubuntu/lighttable
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpwybqddzt/secring.gpg' created
gpg: keyring `/tmp/tmpwybqddzt/pubring.gpg' created
gpg: requesting key 85C79C73 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpwybqddzt/trustdb.gpg: trustdb created
gpg: key 85C79C73: public key "Launchpad PPA for Anton Yakutovich" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
$ sudo apt-get update
......
$ sudo apt-get install lighttable-installer
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
lighttable-installer
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 4292 B of archives.
After this operation, 20.5 kB of additional disk space will be used.
Get:1 https://ppa.launchpad.net/dr-akulavich/lighttable/ubuntu/ trusty/main lighttable-installer amd64 0.8.0-1~ppa~3 [4292 B]
Fetched 4292 B in 0s (18.6 kB/s)
.......
Download done.
Removing outdated cached downloads...
Unpacking lighttable-installer (0.8.0-1~ppa~3) ...
Processing triggers for mime-support (3.54ubuntu1.1) ...
Setting up lighttable-installer (0.8.0-1~ppa~3) ...
Successfully installed in /opt/LightTable
希望這能幫助您解決 PPA 問題。 如果沒有,或者您有其他問題,請在文章下方給我們留言。
另請閱讀:
在 Ubuntu 上添加/刪除 PPA 存儲庫