更新 Ubuntu 18.04 安装时出现问题
sudo apt update
工作正常,那么
sudo apt upgrade
失败
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
libgdk-pixbuf2.0-0 : Depends: libglib2.0-0 (= 6= 2.48.0) but 2.56.3-0ubuntu0.18.04.1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
然后运行:
sudo apt --fix-broken install
给出
The following additional packages will be installed:
libgdk-pixbuf2.0-0
The following packages will be upgraded:
libgdk-pixbuf2.0-0
其次是:
dpkg: warning: parsing file '/var/lib/dpkg/status' near line 14881 package 'libgdk-pixbuf2.0-0:amd64':
'Depends' field, reference to 'libglib2.0-0':
implicit exact match on version number, suggest using '=' instead
dpkg: error: parsing file '/var/lib/dpkg/status' near line 14881 package 'libgdk-pixbuf2.0-0:amd64':
'Depends' field, reference to 'libglib2.0-0': version contains ' '
E: Sub-process /usr/bin/dpkg returned an error code (2)
编辑:
$ apt-cache policy libgdk-pixbuf2.0-0:amd64 libglib2.0-0
libgdk-pixbuf2.0-0:
Installed: 2.36.11-2
Candidate: 2.36.11-2
Version table:
2.36.11-2 500
500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
*** 2.36.11-2 100
100 /var/lib/dpkg/status
libglib2.0-0:
Installed: 2.56.3-0ubuntu0.18.04.1
Candidate: 2.56.3-0ubuntu0.18.04.1
Version table:
*** 2.56.3-0ubuntu0.18.04.1 100
100 /var/lib/dpkg/status
2.56.1-2ubuntu1 500
500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
编辑2:重新启用包源后
$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:2 http://gb.archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://gb.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Fetched 177 kB in 0s (384 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
122 packages can be upgraded. Run 'apt list --upgradable' to see them.
然后
$ sudo apt full-upgrade
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.
libgdk-pixbuf2.0-0 : Depends: libglib2.0-0 (= 6= 2.48.0) but 2.56.3-0ubuntu0.18.04.1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
$ apt-cache policy libgdk-pixbuf2.0-0:amd64 libglib2.0-0
libgdk-pixbuf2.0-0:
Installed: 2.36.11-2
Candidate: 2.36.11-2
Version table:
2.36.11-2 500
500 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
*** 2.36.11-2 100
100 /var/lib/dpkg/status
libglib2.0-0:
Installed: 2.56.3-0ubuntu0.18.04.1
Candidate: 2.56.3-0ubuntu0.18.04.1
Version table:
*** 2.56.3-0ubuntu0.18.04.1 500
500 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
100 /var/lib/dpkg/status
2.56.2-0ubuntu0.18.04.2 500
500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
2.56.1-2ubuntu1 500
500 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
答案1
尝试下载两个有问题的软件包,然后使用以下命令强制安装它们:
apt-get download libgdk-pixbuf2.0-0=2.36.11-2 libglib2.0-0=2.56.3-0ubuntu0.18.04.1
sudo dpkg -i --force-all lib*.deb
答案2
我通过编辑 /var/lib/dpkg/status 文件并将 libglib2.0-0(6=2.48.0) 更改为 (=2.48.0) 来修复它 - 然后执行了 apt update/upgrade