![为什么默认安装建议的软件包?](https://linux22.com/image/1022615/%E4%B8%BA%E4%BB%80%E4%B9%88%E9%BB%98%E8%AE%A4%E5%AE%89%E8%A3%85%E5%BB%BA%E8%AE%AE%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%8C%85%EF%BC%9F.png)
当我发现通过安装时firefoxdriver
,chromium 的东西也会被安装时,我感到很惊讶:
$ sudo apt install firefoxdriver
[sudo] password for asuka:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
chromium-browser chromium-chromedriver python3-selenium
The following NEW packages will be installed:
chromium-browser chromium-chromedriver firefoxdriver python3-selenium
0 upgraded, 4 newly installed, 0 to remove and 7 not upgraded.
Need to get 802 kB of archives.
After this operation, 1,645 kB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.
我深入研究后发现,这firefoxdriver
取决于python3-selenium
:
$ apt show firefoxdriver
Package: firefoxdriver
...
Depends: libc6 (>= 2.4), firefox-esr | firefox, python-selenium (>= 3.14.1) | python3-selenium (>= 3.14.1)
...
并python3-selenium
建议,我猜这就是引入铬包的chromium-driver
原因。firefoxdriver
$ apt show python3-selenium
Package: python3-selenium
...
Recommends: chromium-driver | chromedriver | phantomjs
...
我的猜测正确吗?如果正确,为什么默认安装推荐的软件包?
答案1
Recommends
并且Suggests
是不同的类别。
您的输出显示Recommends
(不是Suggests
)。
Ubuntu 的默认设置是安装Recommends
和不安装Suggests
。您可以按照以下方法查看当前设置:
$ apt-config dump | grep Suggests
APT::Install-Suggests "0"; // 0 = No
$ apt-config dump | grep Recommends
APT::Install-Recommends "1"; // 1 = Yes
当然,您可以通过多种方式更改设置。
进行一次性更改的最简单方法是使用 apt 的--no-install-recommends
标志。例如:sudo apt install hello --no-install-recommends
对于大多数人来说,进行频繁更改的最简单方法是使用文件更改设置/etc/apt/apt.conf.d/