我怎样才能阻止 apt 安装 snap 包?

我怎样才能阻止 apt 安装 snap 包?

sudo apt-get install chromium-browser由于某种原因,没有安装正确的 apt-get 包,但安装了 chromium snap。

我知道阻止此类安装不会奇迹般地建立维护包,并且会导致安装失败。但我更喜欢获取错误并手动安装 - 从源代码或(不太可能)从 snap 安装。

我永远不想使用 snap 安装任何东西(首先,由于 Snap Store 的闭源做法)。尤其是当我使用 安装时,不要默默地安装apt-get

如何在 gnome 软件中心禁用快照?没有回答我的问题,因为我想摆脱 snap 的侵扰apt- 而不是在 gnome-software-center 中。

答案1

您必须通过以下方式从系统中删除 snapd

sudo apt-get autopurge snapd

然后为 APT 创建特殊的配置文件,就像 LinuxMint 一样做过

cat <<EOF | sudo tee /etc/apt/preferences.d/nosnap.pref
# To prevent repository packages from triggering the installation of Snap,
# this file forbids snapd from being installed by APT.
# For more information: https://linuxmint-user-guide.readthedocs.io/en/latest/snap.html

Package: snapd
Pin: release a=*
Pin-Priority: -10
EOF

这将阻止将来安装 Snaps。

答案2

除了在中设置文件之外/etc/apt,您还可以在清除 snapd 之后运行apt-mark来阻止安装任何需要的东西:snapd

$ sudo apt-mark hold snapd

例如,firefox在 Ubuntu 22.04(基于 snapd 的软件包)中安装会出现错误:

$ sudo apt install firefox
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 firefox : PreDepends: snapd but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

打破这个规则的唯一方法就是明确地这样做:

$ sudo apt install snapd
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  snapd
The following held packages will be changed:
  snapd
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 23.8 MB of archives.
After this operation, 102 MB of additional disk space will be used.
Do you want to continue? [Y/n]

另外,您可以通过以下方式撤消效果:

$ sudo apt-mark unhold snapd

相关内容