strict.pm 没有 return 在 (eval 1) 第 2 行的真实值

strict.pm did not return a true value at (eval 1) line 2

我有一台 VPS 安装了以下系统:

CPU model            : Common KVM processor
Number of cores      : 1
CPU frequency        : 2499.998 MHz
Total size of Disk   : 30.0 GB (6.0 GB Used)
Total amount of Mem  : 1995 MB (1043 MB Used)
Total amount of Swap : 0 MB (0 MB Used)
OS                   : Debian GNU/Linux 10
Arch                 : x86_64 (64 Bit)
Kernel               : 4.19.0-8-amd64

仅安装了 Mailcow(码头化)。然后我想安装一些像 sudo 这样的包,由于某种原因弹出以下错误:

root@mx:~#  aptitude upgrade
The following packages will be upgraded:
  docker-ce docker-ce-cli
The following partially installed packages will be configured:
  debconf
The following packages are RECOMMENDED but will NOT be installed:
  aufs-tools cgroupfs-mount libltdl7 pigz
2 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/65.4 MB of archives. After unpacking 19.5 kB will be used.
Do you want to continue? [Y/n/?]
debconf: Perl may be unconfigured (strict.pm did not return a true value at (eval 1) line 2.
BEGIN failed--compilation aborted at (eval 1) line 2.
) -- aborting
Setting up debconf (1.5.71) ...
strict.pm did not return a true value at /usr/share/debconf/frontend line 5.
BEGIN failed--compilation aborted at /usr/share/debconf/frontend line 5.
dpkg: error processing package debconf (--configure):
 installed debconf package post-installation script subprocess returned error exit status 255
Errors were encountered while processing:
 debconf
E: Sub-process /usr/bin/dpkg returned an error code (1)

这个错误引起了我的注意:

debconf: Perl may be unconfigured (strict.pm did not return a true value at (eval 1) line 2.
BEGIN failed--compilation aborted at (eval 1) line 2.
) -- aborting

我一直在尝试解决这个问题,但没有成功。

尝试#1: perl -e 'use strict' returns 这个:

strict.pm did not return a true value at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

尝试#2: cd /var/cache/apt/archives,然后 dpkg -i perl_5.28.1-6_amd64.deb 和 dpkg -i perl-base_5.28.1-6_amd64.deb 结果如下:

root@mx:~# cd /var/cache/apt/archives
root@mx:/var/cache/apt/archives# dpkg -i perl-base_5.28.1-6_amd64.deb
(Reading database ... 40477 files and directories currently installed.)
Preparing to unpack perl-base_5.28.1-6_amd64.deb ...
Unpacking perl-base (5.28.1-6) over (5.28.1-6) ...
Setting up perl-base (5.28.1-6) ...
root@mx:/var/cache/apt/archives# dpkg -i perl_5.28.1-6_amd64.deb
Selecting previously unselected package perl.
(Reading database ... 40477 files and directories currently installed.)
Preparing to unpack perl_5.28.1-6_amd64.deb ...
Unpacking perl (5.28.1-6) over (5.28.1-6) ...
Setting up perl (5.28.1-6) ...
root@mx:/var/cache/apt/archives#

尝试#3:

apt reinstall perl results in this:
root@mx:/var/cache/apt/archives# apt reinstall perl
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 2 not upgraded.
1 not fully installed or removed.
Need to get 0 B/204 kB of archives.
After this operation, 0 B of additional disk space will be used.
debconf: Perl may be unconfigured (strict.pm did not return a true value at (eval 1) line 2.
BEGIN failed--compilation aborted at (eval 1) line 2.
) -- aborting
Setting up debconf (1.5.71) ...
strict.pm did not return a true value at /usr/share/debconf/frontend line 5.
BEGIN failed--compilation aborted at /usr/share/debconf/frontend line 5.
dpkg: error processing package debconf (--configure):
 installed debconf package post-installation script subprocess returned error exit status 255
Errors were encountered while processing:
 debconf
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@mx:/var/cache/apt/archives#

尝试#4: 由于未安装 perl5,我尝试清除 perl 并使用 apt remove --purge perl && sudo apt install perl 重新安装它 结果是:

root@mx:/var/cache/apt/archives# apt remove --purge perl && sudo apt install perl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  git-man libapt-pkg-perl libcurl3-gnutls libgdbm-compat4 libgdbm6 libperl5.28 patch perl-modules-5.28
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  apt-file* git* libcgi-fast-perl* libcgi-pm-perl* libclass-accessor-perl* libencode-locale-perl* liberror-perl* libexporter-tiny-perl* libfcgi-perl* libhtml-parser-perl* libhtml-tagset-perl*
  libhttp-date-perl* libhttp-message-perl* libio-html-perl* libio-string-perl* liblist-moreutils-perl* liblwp-mediatypes-perl* libparse-debianchangelog-perl* libregexp-assemble-perl* libsub-name-perl*
  libtimedate-perl* liburi-perl* perl*
0 upgraded, 0 newly installed, 23 to remove and 2 not upgraded.
1 not fully installed or removed.
After this operation, 39.4 MB disk space will be freed.
Do you want to continue? [Y/n]
debconf: Perl may be unconfigured (strict.pm did not return a true value at (eval 1) line 2.
BEGIN failed--compilation aborted at (eval 1) line 2.
) -- aborting
Setting up debconf (1.5.71) ...
strict.pm did not return a true value at /usr/share/debconf/frontend line 5.
BEGIN failed--compilation aborted at /usr/share/debconf/frontend line 5.
dpkg: error processing package debconf (--configure):
 installed debconf package post-installation script subprocess returned error exit status 255
Errors were encountered while processing:
 debconf
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@mx:/var/cache/apt/archives#

尝试#5: perl -V returns 这个:

root@mx:/usr/share/perl/5.28.1# perl -V
strict.pm did not return a true value at /usr/lib/x86_64-linux-gnu/perl/5.28/Config.pm line 9.
BEGIN failed--compilation aborted at /usr/lib/x86_64-linux-gnu/perl/5.28/Config.pm line 9.
Compilation failed in require.
BEGIN failed--compilation aborted.

关于 strict.pm,它似乎位于 /usr/share/perl/5.28.1/strict.pm 并且包含大量长行,内容如下:

^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^ (and so on ..)

"fixed" 只需将其替换为

1;
__END__

但现在出现以下错误:

debconf: Perl may be unconfigured (IO/File.pm did not return a true value at /usr/share/perl/5.28/FileHandle.pm line 9.

那个文件 IO/File.pm 似乎不存在 - 手动添加它没有帮助。

尝试#6: 在@ikegami(评论)的帮助下,strict.pm 已修复,但以下文件似乎仍然损坏(特别是 IO/File.pm):

Setting up debconf (1.5.71) ...
IO/File.pm did not return a true value at /usr/share/perl/5.28/FileHandle.pm line 9.
Compilation failed in require at /usr/share/perl5/Debconf/Template.pm line 8.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Template.pm line 8.
Compilation failed in require at /usr/share/perl5/Debconf/Question.pm line 8.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Question.pm line 8.
Compilation failed in require at /usr/share/perl5/Debconf/Config.pm line 7.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Config.pm line 7.
Compilation failed in require at /usr/share/perl5/Debconf/Log.pm line 10.
Compilation failed in require at /usr/share/perl5/Debconf/Db.pm line 7.
BEGIN failed--compilation aborted at /usr/share/perl5/Debconf/Db.pm line 7.
Compilation failed in require at /usr/share/debconf/frontend line 7.
BEGIN failed--compilation aborted at /usr/share/debconf/frontend line 7.
dpkg: error processing package debconf (--configure):
 installed debconf package post-installation script subprocess returned error exit status 255
Errors were encountered while processing:
 debconf
E: Sub-process /usr/bin/dpkg returned an error code (1)

信息#1: root@mx:/usr/share/perl/5.28# find /usr/share/perl -name '*.pm' -exec perl

-0777ne'print "$ARGV\n" if /[=24=]/' {} +
/usr/share/perl/5.28.1/Net/FTP/A.pm
/usr/share/perl/5.28.1/Net/FTP/I.pm
/usr/share/perl/5.28.1/Net/FTP/L.pm
/usr/share/perl/5.28.1/Net/FTP/E.pm
/usr/share/perl/5.28.1/Net/FTP/dataconn.pm
/usr/share/perl/5.28.1/Net/FTP.pm
/usr/share/perl/5.28.1/Net/SMTP.pm
/usr/share/perl/5.28.1/Net/hostent.pm
/usr/share/perl/5.28.1/Net/Time.pm
/usr/share/perl/5.28.1/utf8.pm
/usr/share/perl/5.28.1/Pod/Html.pm
/usr/share/perl/5.28.1/Pod/Functions.pm
/usr/share/perl/5.28.1/Pod/Find.pm
/usr/share/perl/5.28.1/sigtrap.pm
/usr/share/perl/5.28.1/perlfaq.pm
/usr/share/perl/5.28.1/subs.pm
/usr/share/perl/5.28.1/IO/Socket/IP.pm
/usr/share/perl/5.28.1/IO/Compress/Zlib/Constants.pm
/usr/share/perl/5.28.1/IO/Compress/Zlib/Extra.pm
/usr/share/perl/5.28.1/IO/Compress/Gzip/Constants.pm
/usr/share/perl/5.28.1/IO/Compress/Gzip.pm
/usr/share/perl/5.28.1/IO/Compress/RawDeflate.pm
/usr/share/perl/5.28.1/IO/Uncompress/RawInflate.pm
/usr/share/perl/5.28.1/IO/Uncompress/Adapter/Identity.pm
/usr/share/perl/5.28.1/IO/Uncompress/Adapter/Bunzip2.pm
/usr/share/perl/5.28.1/IO/Uncompress/Base.pm
/usr/share/perl/5.28.1/IO/Uncompress/Unzip.pm
/usr/share/perl/5.28.1/IO/Uncompress/Bunzip2.pm
/usr/share/perl/5.28.1/vmsish.pm
/usr/share/perl/5.28.1/Locale/Codes/LangFam_Codes.pm
/usr/share/perl/5.28.1/Locale/Codes/LangVar.pm
/usr/share/perl/5.28.1/Locale/Codes/LangExt_Retired.pm
/usr/share/perl/5.28.1/Locale/Codes/LangFam_Retired.pm
/usr/share/perl/5.28.1/Locale/Codes/LangFam.pm
/usr/share/perl/5.28.1/Test2/API/Stack.pm
/usr/share/perl/5.28.1/Test2/Event.pm
/usr/share/perl/5.28.1/Test2/API.pm
/usr/share/perl/5.28.1/Test2/Event/Waiting.pm
/usr/share/perl/5.28.1/Test2/EventFacet/Info.pm
/usr/share/perl/5.28.1/Test2/EventFacet/Amnesty.pm
/usr/share/perl/5.28.1/Test2/EventFacet/About.pm
/usr/share/perl/5.28.1/Test2/EventFacet/Assert.pm
/usr/share/perl/5.28.1/Test2/EventFacet/Hub.pm
/usr/share/perl/5.28.1/Test2/EventFacet/Control.pm
/usr/share/perl/5.28.1/Test2/EventFacet/Error.pm
/usr/share/perl/5.28.1/overload/numbers.pm
/usr/share/perl/5.28.1/sort.pm
/usr/share/perl/5.28.1/parent.pm

信息#2: root@mx: 查找 / -name "File.pm"

/usr/share/perl/5.28.1/Archive/Tar/File.pm
/usr/share/perl/5.28.1/TAP/Parser/SourceHandler/File.pm
/usr/share/perl/5.28.1/TAP/Formatter/File.pm
/usr/share/perl/5.28.1/Tie/File.pm
/usr/share/perl5/Debconf/DbDriver/File.pm
/usr/lib/x86_64-linux-gnu/perl/5.28.1/IO/File.pm
/usr/lib/x86_64-linux-gnu/perl-base/IO/File.pm

发出以下命令应该可以修复足够多的损坏文件,以便您可以使用 apt:

重新安装 Perl
>/usr/share/perl/5.28.1/utf8.pm                             curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/lib/utf8.pm
>/usr/share/perl/5.28.1/subs.pm                             curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/lib/subs.pm
>/usr/share/perl/5.28.1/IO/Socket/IP.pm                     curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Socket-IP/lib/IO/Socket/IP.pm
>/usr/share/perl/5.28.1/IO/Compress/Zlib/Constants.pm       curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Compress/Zlib/Constants.pm
>/usr/share/perl/5.28.1/IO/Compress/Zlib/Extra.pm           curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Compress/Zlib/Extra.pm
>/usr/share/perl/5.28.1/IO/Compress/Gzip/Constants.pm       curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Compress/Gzip/Constants.pm
>/usr/share/perl/5.28.1/IO/Compress/Gzip.pm                 curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Compress/Gzip.pm
>/usr/share/perl/5.28.1/IO/Compress/RawDeflate.pm           curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Compress/RawDeflate.pm
>/usr/share/perl/5.28.1/IO/Uncompress/RawInflate.pm         curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Uncompress/RawInflate.pm
>/usr/share/perl/5.28.1/IO/Uncompress/Adapter/Identity.pm   curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm
>/usr/share/perl/5.28.1/IO/Uncompress/Adapter/Bunzip2.pm    curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm
>/usr/share/perl/5.28.1/IO/Uncompress/Base.pm               curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Uncompress/Base.pm
>/usr/share/perl/5.28.1/IO/Uncompress/Unzip.pm              curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Uncompress/Unzip.pm
>/usr/share/perl/5.28.1/IO/Uncompress/Bunzip2.pm            curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/IO-Compress/lib/IO/Uncompress/Bunzip2.pm
>/usr/share/perl/5.28.1/overload/numbers.pm                 curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/lib/overload/numbers.pm
>/usr/share/perl/5.28.1/sort.pm                             curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/lib/sort.pm
>/usr/share/perl/5.28.1/parent.pm                           curl https://raw.githubusercontent.com/Perl/perl5/v5.28.1/cpan/parent/lib/parent.pm