当我执行以下操作时,出现处理包错误apt upgrade
:
我尝试过网上提到的常见解决方案。但它陷入了循环。
❯ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
mysql-server-5.7 : PreDepends: mysql-common (>= 5.5) but it is not installed
Depends: apparmor (>= 2.10) but it is not installed
Depends: mysql-client-5.7 (>= 5.7.32-0ubuntu0.16.04.1) but it is not installed
Depends: mysql-common (>= 5.6.22-1~) but it is not installed
Depends: mysql-server-core-5.7 (= 5.7.32-0ubuntu0.16.04.1) but it is not installed
Recommends: libhtml-template-perl but it is not installed
phpmyadmin : Depends: libapache2-mod-php or
libapache2-mod-phpfilter but it is not installable or
php-cgi or
php-fpm or
php
Depends: php-mysql but it is not installed or
php-mysqli or
php-mysqlnd
Depends: php-json
Depends: php-common but it is not installed
Depends: libjs-sphinxdoc (>= 1.0) but it is not installed
Depends: dbconfig-mysql but it is not installed or
dbconfig-no-thanks but it is not installed or
dbconfig-common (< 2.0.0) but it is not installed
Depends: php-gettext
Depends: php-mbstring
Depends: php-phpseclib (>= 2.0)
Recommends: php-gd
Recommends: mysql-client but it is not installed or
mariadb-client but it is not installed or
virtual-mysql-client
Recommends: php-tcpdf but it is not installed
E: Unmet dependencies. Try using -f.
然后我尝试:
❯ sudo apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
apparmor dbconfig-common dbconfig-mysql libapache2-mod-php libapache2-mod-php7.0
libapparmor-perl libjs-sphinxdoc libjs-underscore mysql-client-5.7
mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 php-common
php-gettext php-mbstring php-mysql php-pear php-phpseclib php-xml php7.0-cli
php7.0-common php7.0-json php7.0-mbstring php7.0-mysql php7.0-opcache php7.0-readline
php7.0-xml
Suggested packages:
apparmor-profiles apparmor-profiles-extra apparmor-docs apparmor-utils mysql-server
| mariadb-server mailx tinyca php-libsodium php-mcrypt php-gmp
Recommended packages:
libhtml-template-perl
The following NEW packages will be installed:
apparmor dbconfig-common dbconfig-mysql libapache2-mod-php libapache2-mod-php7.0
libapparmor-perl libjs-sphinxdoc libjs-underscore mysql-client-5.7
mysql-client-core-5.7 mysql-common mysql-server-core-5.7 php-common php-gettext
php-mbstring php-mysql php-pear php-phpseclib php-xml php7.0-cli php7.0-common
php7.0-json php7.0-mbstring php7.0-mysql php7.0-opcache php7.0-readline php7.0-xml
The following packages will be upgraded:
mysql-server-5.7
1 upgraded, 27 newly installed, 0 to remove and 0 not upgraded.
14 not fully installed or removed.
Need to get 20.7 MB/23.2 MB of archives.
After this operation, 131 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
...
Selecting previously unselected package php-phpseclib.
Preparing to unpack .../php-phpseclib_2.0.1-1build1_all.deb ...
Unpacking php-phpseclib (2.0.1-1build1) ...
Processing triggers for man-db (2.7.5-1) ...
Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-5.7_5.7.33-0ubuntu0.16.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
然后:
❯ sudo dpkg --configure -a
Setting up grub-pc (2.02~beta2-36ubuntu3.29) ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: error processing package grub-pc (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up tzdata (2021a-0ubuntu0.16.04) ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: error processing package tzdata (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up samba-common (2:4.3.11+dfsg-0ubuntu0.16.04.32) ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: error processing package samba-common (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up openssh-server (1:7.2p2-4ubuntu2.10) ...
debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
dpkg: error processing package openssh-server (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of samba:
samba depends on samba-common (= 2:4.3.11+dfsg-0ubuntu0.16.04.32); however:
Package samba-common is not configured yet.
dpkg: error processing package samba (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ubuntu-minimal:
ubuntu-minimal depends on tzdata; however:
Package tzdata is not configured yet.
...
dpkg: error processing package python-pip-whl (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of nodejs:
nodejs depends on ca-certificates; however:
Package ca-certificates is not configured yet.
dpkg: error processing package nodejs (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
grub-pc
tzdata
samba-common
openssh-server
samba
ubuntu-minimal
samba-common-bin
ca-certificates
python-pip
software-properties-common
python-pip-whl
nodejs
我尝试删除此处列出的软件包
❯ sudo apt-get remove $pkg -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'libapache2-mod-php7.0' is not installed, so not removed
Package 'mysql-server' is not installed, so not removed
Package 'php-pear' is not installed, so not removed
Package 'php7.0-cli' is not installed, so not removed
Package 'php7.0-common' is not installed, so not removed
Package 'php7.0-gd' is not installed, so not removed
Package 'php7.0-json' is not installed, so not removed
Package 'php7.0-mysql' is not installed, so not removed
Package 'php7.0-opcache' is not installed, so not removed
Package 'php7.0-readline' is not installed, so not removed
Package 'php7.0-xml' is not installed, so not removed
Package 'php7.0-mbstring' is not installed, so not removed
Package 'php7.0-mcrypt' is not installed, so not removed
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
grub-gfxpayload-lists : Depends: grub-pc (>= 1.99~20101210-1ubuntu2)
libtcl8.6 : Depends: tzdata but it is not going to be installed
phpmyadmin : Depends: libapache2-mod-php or
libapache2-mod-phpfilter but it is not installable or
php-cgi or
php-fpm or
php
Depends: php-mysql but it is not going to be installed or
php-mysqli or
php-mysqlnd
Depends: php-json
Depends: php-common but it is not going to be installed
Depends: libjs-sphinxdoc (>= 1.0) but it is not going to be installed
Depends: dbconfig-mysql but it is not going to be installed or
dbconfig-no-thanks but it is not going to be installed or
dbconfig-common (< 2.0.0) but it is not going to be installed
Depends: php-gettext
Depends: php-mbstring
Depends: php-phpseclib (>= 2.0)
Recommends: php-gd
Recommends: mysql-client but it is not going to be installed or
mariadb-client but it is not going to be installed or
virtual-mysql-client
Recommends: php-tcpdf but it is not going to be installed
python3-requests : Depends: ca-certificates but it is not going to be installed
rubygems-integration : Depends: ca-certificates but it is not going to be installed
ssh-import-id : Depends: ca-certificates but it is not going to be installed
Recommends: openssh-server
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
这让我们回到安装步骤。我该如何解决这个问题并升级所有内容apt-get
?
操作系统:Ubuntu 16.04.7 LTS x86_64
贝壳:鱼 3.1.2
答案1
您的…is locked by another process…
情况很可能是由另一个正在运行的dpkg
进程引起的。这可能是先前失败的包配置运行留下的。
如果您确定没有在另一个窗口中运行dpkg
等apt
,请查看现有dpkg
进程并考虑kill
使用它们。
$ ps awux | grep dpkg
至于其他错误,都是由一个或多个软件包在安装时配置失败引起的。如果不查看实际发生的日志,就不可能找出原因。
如果您确定不需要这些软件包,可以将其删除,直到问题消失。/var/lib/dpkg/info/
例如,如果由于 rm 前或后脚本中的问题而导致删除软件包失败,您可以在 中找到这些脚本/var/lib/dpkg/info/mysql-server.postrm
,然后将其删除。显然,如果您想保留这些软件包,那么这是“核选项”,而不是明智的做法。如果您要立即重新安装它们,应该没问题。
我不推荐您所追求的大规模移除策略。删除重要的东西并完全破坏您的安装太容易了。尝试专注于解决单个包的安装问题。 apt 的输出很擅长告诉你什么依赖于什么。按照依赖关系来解决这个问题。
为了帮助解决未来的问题,请保留安装失败的日志。我们无法提供适当的帮助,因为我们不明白为什么这些软件包首先无法配置。
答案2
也遇到了这个问题。最后,我的引导分区已满到最后一个字节。一些旧的更新没有被正确删除。手动删除较大和较旧的文件并重新启动。又工作了
要检查您的(启动)分区大小,请使用“baobab”等工具https://linux.die.net/man/1/baobab。
!在删除文件之前请仔细检查文件名!你可能会弄乱你的系统