dpkg: 处理软件包 php8.1-common 时出错

dpkg: 处理软件包 php8.1-common 时出错

我知道我的错误非常典型,我遇到它时并不是故意的,而且我需要解决这个问题,因为我正在使用 php。

❯ php
zsh: command not found: php

和:

❯ sudo apt-get install php
Reading package lists... Done
Building dependency tree       
Reading state information... Done
php is already the newest version (2:8.1+92+ubuntu20.04.1+deb.sury.org+2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
7 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up php8.1-common (8.1.7-1+ubuntu20.04.1+deb.sury.org+1) ...
/usr/bin/ucf: line 569: awk: command not found
dpkg: error processing package php8.1-common (--configure):
 installed php8.1-common package post-installation script subprocess returned error exit status 127
No apport report written because the error message indicates its a followup error from a previous failure.
              dpkg: dependency problems prevent configuration of php8.1:
 php8.1 depends on php8.1-common; however:
  Package php8.1-common is not configured yet.

dpkg: error processing package php8.1 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php8.1-cli:
 php8.1-cli depends on php8.1-common (= 8.1.7-1+ubuntu20.04.1+deb.sury.org+1); however:
  Package php8.1-common is not configured yet.

dpkg: error processing package php8.1-cli (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php8.1-readline:
 php8.1-readline depends on php8.1-common (= 8.1.7-1+ubuntu20.04.1+deb.sury.org+1); however:
  Package php8.1-common is not configured yet.

dpkg: error processing package php8.1-readline (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libapache2-mod-php8.1:
 libapache2-mod-php8.1 depends on php8.1-cli; however:
  Package phpNo apport report written because the error message indicates its a followup error from a previous failure.
                           No apport report written because MaxReports is reached already
                                                                                         No apport report written because MaxReports is reached already
                                                           No apport report written because MaxReports is reached already
                             No apport report written because MaxReports is reached already
                                                                                           8.1-cli is not configured yet.
 libapache2-mod-php8.1 depends on php8.1-common (= 8.1.7-1+ubuntu20.04.1+deb.sury.org+1); however:
  Package php8.1-common is not configured yet.

dpkg: error processing package libapache2-mod-php8.1 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php8.1-opcache:
 php8.1-opcache depends on php8.1-common (= 8.1.7-1+ubuntu20.04.1+deb.sury.org+1); however:
  Package php8.1-common is not configured yet.

dpkg: error processing package php8.1-opcache (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php:
 php depends on php8.1; however:
  Package php8.1 is not configured yet.

dpkg: error processing package php (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 php8.1-common
 php8.1
 php8.1-cli
 php8.1-readline
 libapache2-mod-php8.1
 php8.1-opcache
 php

和 :

❯ sudo dpkg --configure -a
Setting up php8.1-common (8.1.7-1+ubuntu20.04.1+deb.sury.org+1) ...
/usr/bin/ucf: line 569: awk: command not found
dpkg: error processing package php8.1-common (--configure):
 installed php8.1-common package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of php8.1:
 php8.1 depends on php8.1-common; however:
  Package php8.1-common is not configured yet.

dpkg: error processing package php8.1 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php8.1-cli:
 php8.1-cli depends on php8.1-common (= 8.1.7-1+ubuntu20.04.1+deb.sury.org+1); however:
  Package php8.1-common is not configured yet.

dpkg: error processing package php8.1-cli (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php8.1-readline:
 php8.1-readline depends on php8.1-common (= 8.1.7-1+ubuntu20.04.1+deb.sury.org+1); however:
  Package php8.1-common is not configured yet.

dpkg: error processing package php8.1-readline (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libapache2-mod-php8.1:
 libapache2-mod-php8.1 depends on php8.1-cli; however:
  Package php8.1-cli is not configured yet.
 libapache2-mod-php8.1 depends on php8.1-common (= 8.1.7-1+ubuntu20.04.1+deb.sury.org+1); however:
  Package php8.1-common is not configured yet.

dpkg: error processing package libapache2-mod-php8.1 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php8.1-opcache:
 php8.1-opcache depends on php8.1-common (= 8.1.7-1+ubuntu20.04.1+deb.sury.org+1); however:
  Package php8.1-common is not configured yet.

dpkg: error processing package php8.1-opcache (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php:
 php depends on php8.1; however:
  Package php8.1 is not configured yet.

dpkg: error processing package php (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 php8.1-common
 php8.1
 php8.1-cli
 php8.1-readline
 libapache2-mod-php8.1
 php8.1-opcache
 php

我不知道具体该怎么做,我执行了 apt purge 并重新安装了 php,但问题仍然存在。我该怎么做才能解决这个问题?不要再为 awk 错误烦恼了,谢谢大家 :')

答案1

从错误消息中检查这一行: /usr/bin/ucf: line 569: awk: command not found。这意味着您的 PC 需要awk文本处理工具来配置 PHP 包,但找不到它已安装。

这很奇怪,因为awk非常所有 Linux 系统默认安装的基本系统包。您的系统非常依赖它才能正常运行。

从你对错误的评论来看too many levels of symbolic links,听起来你awk有点符号链接指向自身(或者可能是指向另一个符号链接,而后者又链接到第一个符号链接),这导致您的系统不断重复相同的链接,并且(显然)无法找到实际程序。如果您错误地运行了某个命令,或者awk错误地删除了某个程序,则可能会发生这种情况。

最简单的解决方案是awk使用重新安装apt。重新安装软件包通常可以修复损坏的符号链接,因为安装过程的一部分通常是创建系统识别软件包所需的所有符号链接。Ubuntu 22.04 默认附带gawkmawk软件包,它们都提供实用程序。使用awk安装其中任何一个或其他版本(awk例如 )可以解决此问题。如果您选择的那个确实已经安装,请添加标志以强制安装它(因为这样应该可以修复损坏的符号链接)。例如,使用。awk-originalapt--reinstallaptapt install --reinstall gawk

相关内容