无法安装/删除新软件包 - apt --fix-broken install

无法安装/删除新软件包 - apt --fix-broken install

我在这里迷路了。我试图在我的 ubuntu 笔记本电脑上安装 openssh-server,但有一些冲突我无法修复。

$ sudo apt install openssh-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 kubeadm : Depends: kubernetes-cni (>= 0.8.7)
 kubelet : Depends: kubernetes-cni (>= 0.8.7)
 openssh-server : Depends: openssh-sftp-server
                  Recommends: ncurses-term but it is not going to be installed
                  Recommends: ssh-import-id but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).


$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  kubernetes-cni
The following NEW packages will be installed:
  kubernetes-cni
0 upgraded, 1 newly installed, 0 to remove and 76 not upgraded.
7 not fully installed or removed.
Need to get 0 B/25.0 MB of archives.
After this operation, 72.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
dpkg: regarding .../kubernetes-cni_0.8.7-00_amd64.deb containing kubernetes-cni:
 containernetworking-plugins conflicts with kubernetes-cni
  kubernetes-cni (version 0.8.7-00) is to be installed.

dpkg: error processing archive /var/cache/apt/archives/kubernetes-cni_0.8.7-00_amd64.deb (--unpack):
 conflicting packages - not installing kubernetes-cni
Errors were encountered while processing:
 /var/cache/apt/archives/kubernetes-cni_0.8.7-00_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

还尝试了以下方法:

$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/kubernetes-cni_0.8.7-00_amd64.deb
dpkg: regarding .../kubernetes-cni_0.8.7-00_amd64.deb containing kubernetes-cni:
 containernetworking-plugins conflicts with kubernetes-cni
  kubernetes-cni (version 0.8.7-00) is to be installed.

dpkg: error processing archive /var/cache/apt/archives/kubernetes-cni_0.8.7-00_amd64.deb (--install):
 conflicting packages - not installing kubernetes-cni
Errors were encountered while processing:
 /var/cache/apt/archives/kubernetes-cni_0.8.7-00_amd64.deb

我尝试卸载/重新安装 containernetworking-plugins、kubelet 和 kubeadm,但总是出现同样的错误。

$ sudo apt purge containernetworking-plugins
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 kubeadm : Depends: kubernetes-cni (>= 0.8.7)
 kubelet : Depends: kubernetes-cni (>= 0.8.7)
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

$ sudo apt purge kubeadm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 kubelet : Depends: kubernetes-cni (>= 0.8.7)
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

$ sudo apt purge kubelet
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 kubeadm : Depends: kubelet (>= 1.13.0) but it is not going to be installed
           Depends: kubernetes-cni (>= 0.8.7)
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

知道如何修复这个问题吗?

答案1

好的...直接处理 dpkg 就可以了。

$ sudo dpkg -r kubeadm
(Reading database ... 204269 files and directories currently installed.)
Removing kubeadm (1.22.2-00) ...

$ sudo dpkg -r kubelet
(Reading database ... 204268 files and directories currently installed.)
Removing kubelet (1.22.2-00) ...

$ sudo dpkg -r podman
(Reading database ... 204266 files and directories currently installed.)
Removing podman (100:3.3.1-1) ...
Processing triggers for man-db (2.9.1-1) ...

现在我可以安装任何我需要的东西了:)

相关内容