在 Debian 11 上安装、升级、修复时 Apt 返回错误

在 Debian 11 上安装、升级、修复时 Apt 返回错误

我遇到了麻烦apt:每当我尝试upgradeinstall--fix-broken,我都会收到错误,并且没有任何内容得到升级、安装或修复。

下面是我收到的错误的示例。

root@server:~$ apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  libicu63 libperl5.28 libreadline7
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "it_IT.UTF-8",
    LC_MONETARY = "it_IT.UTF-8",
    LC_ADDRESS = "it_IT.UTF-8",
    LC_TELEPHONE = "it_IT.UTF-8",
    LC_NAME = "it_IT.UTF-8",
    LC_MEASUREMENT = "it_IT.UTF-8",
    LC_IDENTIFICATION = "it_IT.UTF-8",
    LC_NUMERIC = "it_IT.UTF-8",
    LC_PAPER = "it_IT.UTF-8",
    LANG = "C"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Can't exec "locale": No such file or directory at /usr/share/perl5/Debconf/Encoding.pm line 16.
Use of uninitialized value $Debconf::Encoding::charmap in scalar chomp at /usr/share/perl5/Debconf/Encoding.pm line 17.
Setting up initramfs-tools (0.140) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.140) ...
update-initramfs: Generating /boot/initrd.img-5.10.0-21-amd64
E: no ldd around - install libc-bin
update-initramfs: failed for /boot/initrd.img-5.10.0-21-amd64 with 1.
dpkg: error processing package initramfs-tools (--configure):
 installed initramfs-tools package post-installation script subprocess returned 
error exit status 1
Errors were encountered while processing:
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

附加信息:

root@server:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/root/work/bin

附加信息2:

root@server:~$ apt install libc-bin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libc-bin : Depends: libc6 (< 2.32) but 2.36-8 is to be installed
E: Unable to correct problems, you have held broken packages.

我也跑过:dpkg --install libc-bin_2.36-8_amd64.deb

附加信息3:

root@server:~$ apt install locales
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
 locales : Depends: libc-bin (> 2.31) but it is not going to be installed
           Depends: debconf (>= 0.5) but it is not going to be installed or
                    debconf-2.0
E: Unable to correct problems, you have held broken packages.
root@server:~$ apt install libc-bin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libc-bin is already the newest version (2.36-8).
The following packages were automatically installed and are no longer required:
  libicu63 libperl5.28 libreadline7
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@server:~$ ldd --version ldd
ldd (Debian GLIBC 2.36-8) 2.36
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

附加信息4:

root@server:~$ apt policy
Package files:
 100 /var/lib/dpkg/status
     release a=now
 100 http://ftp.debian.org/debian bullseye-backports/non-free amd64 Packages
     release o=Debian Backports,a=bullseye-backports,n=bullseye-backports,l=Debian Backports,c=non-free,b=amd64
     origin ftp.debian.org
 100 http://ftp.debian.org/debian bullseye-backports/contrib amd64 Packages
     release o=Debian Backports,a=bullseye-backports,n=bullseye-backports,l=Debian Backports,c=contrib,b=amd64
     origin ftp.debian.org
 100 http://ftp.debian.org/debian bullseye-backports/main amd64 Packages
     release o=Debian Backports,a=bullseye-backports,n=bullseye-backports,l=Debian Backports,c=main,b=amd64
     origin ftp.debian.org
 500 http://security.debian.org/debian-security bullseye-security/main amd64 Packages
     release v=11,o=Debian,a=stable-security,n=bullseye-security,l=Debian-Security,c=main,b=amd64
     origin security.debian.org
 500 http://deb.debian.org/debian bullseye-updates/main amd64 Packages
     release v=11-updates,o=Debian,a=stable-updates,n=bullseye-updates,l=Debian,c=main,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian bullseye/non-free amd64 Packages
     release v=11.6,o=Debian,a=stable,n=bullseye,l=Debian,c=non-free,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian bullseye/contrib amd64 Packages
     release v=11.6,o=Debian,a=stable,n=bullseye,l=Debian,c=contrib,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian bullseye/main amd64 Packages
     release v=11.6,o=Debian,a=stable,n=bullseye,l=Debian,c=main,b=amd64
     origin deb.debian.org
Pinned packages:

答案1

这里要考虑的主要错误是

E: no ldd around - install libc-bin

安装libc-bin应该可以修复您的ldd错误locale

sudo apt install libc-bin

如果失败,您可以下载必要的软件包并手动安装它们,就像您所做的那样libc-bin;您需要确保所有相关软件包使用相同的版本,因此对于 Debian 11:

wget http://deb.debian.org/debian/pool/main/g/glibc/locales_2.31-13+deb11u5_all.deb http://deb.debian.org/debian/pool/main/g/glibc/libc6_2.31-13+deb11u5_amd64.deb http://deb.debian.org/debian/pool/main/g/glibc/libc-bin_2.31-13+deb11u5_amd64.deb
sudo dpkg -i *_2.31-13+deb11u5*.deb

相关内容