问题1:Unmet dependencies. Try ‘apt --fix-broken install‘ with no packages
当你运行 install / remove 都会被打断,报上面错误,就是遇到了依赖出错问题。
运气好的话,你能够输入fix-broken自动解决,但是运气不好就修不好。
问题2:fix-broken报错
这是一个循环的错误:
我运行 apt-get --fix-broken install
,结果报错如下:
Removing sane-utils (1.1.1-5) ...
invoke-rc.d: syntax error: unknown option "--skip-systemd-native"
dpkg: error processing package sane-utils (--remove):
installed sane-utils package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
invoke-rc.d: syntax error: unknown option "--skip-systemd-native"
dpkg: error while cleaning up:
installed sane-utils package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
sane-utils
Processing was halted because there were too many errors.
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
我尝试手动remove sane-utils,结果又让我使用apt --fix-broken install
,死循环了。
尝试如下:
- apt-get remove ubuntu-gnome-desktop 尝试卸载,也不行还是报错
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'ubuntu-gnome-desktop' is not installed, so not removed
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
pipewire-pulse : Depends: pipewire (= 1.0.5-1ubuntu2) but 0.3.48-1ubuntu3 is to be installed
wireplumber : Depends: libglib2.0-0t64 (>= 2.62) but it is not going to be installed
Depends: libpipewire-0.3-0t64 (>= 0.3.68) but it is not going to be installed
Depends: libwireplumber-0.4-0 (= 0.4.17-1ubuntu4) but it is not going to be installed
Depends: pipewire (>= 0.3.68) but 0.3.48-1ubuntu3 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
问题3:明明有些错误不影响系统,但是累计多了,dpkg是会暂停的
就像递归深度不能太deep一样。
报错如下:
dpkg: too many errors, stopping
怎么才能解决这个问题呢?有些error不解决他也是能运行的,但是他直接stop,导致我直接没办法安装需要的包。
解决方法:
- 参考自这个文章:https://askubuntu.com/questions/336795/ubuntu-fix-dependency-problems
第一步
首先备份一下
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bk
This is to backup your sources.list file.
Open up /etc/apt/sources.list with your favorite editor, and delete everything, and repopulate it with the proper, default repositories. Here’s how you’ll get them:
Go here: https://gist.github.com/hakerdefo/9c99e140f543b5089e32176fe8721f5f (我是20.04版本,其他版本自行百度)
Select your country and release.
Select everything in the “Ubuntu Branches” box.
Select everything in the “Ubuntu Updates” box except for the “Proposed” options.
Select everything in the “Ubuntu Partner Repos” box.
Select everything in the “Ubuntu Extras Repos” box.
Scroll down to the very bottom and hit Generate List.
Copy the output of the first box into your sources.list file and save it.
第二步
Run the following commands in order:
sudo apt-get clean
sudo apt-get update
sudo apt-get install -f
sudo dpkg -a --configure
sudo apt-get dist-upgrade
第三步
You’ll probably get some errors along the way. apt-get install -f should try to fix most issues, but I suspect that it won’t fix everything. dpkg will try to further configure the packages, although apt-get install -f should call it by default. The last command is to fully upgrade your system, including the linux kernel, which is what you’re having problems with from the logs you posted. I suggest you, again, run these commands after everything is done:
sudo apt-get install -f
sudo dpkg -a --configure
dist-upgrade 很强大
但是要谨慎使用
常用于:
-
常规系统升级。
-
处理复杂的依赖关系(相当于重装)。
-
发行版升级(不建议,使用do-release-upgrade更好)。
- 在运行之前,建议先更新包列表(sudo apt-get update),并仔细检查它将执行的操作。如果需要升级到新的 Ubuntu 版本,建议使用 do-release-upgrade。
遇到 Sub-process /usr/bin/dpkg returned an error code (1)
就是发生错误
我现在install/remove都会遇到这个错误,感觉系统废了。。。