尝试在 Debian 11 上安装 PostgreSQL 时出错

Errors trying to install PostgreSQL on Debian 11

无法在 Debian 11 上安装 PostgreSQL

第一次安装包:sudo apt install postgresql

...
Unpacking postgresql (13+225) ...
Setting up postgresql-client-common (225) ...
Setting up libpq5:amd64 (13.5-0+deb11u1) ...
Setting up postgresql-client-13 (13.5-0+deb11u1) ...
double free or corruption (!prev)
dpkg: error processing package postgresql-client-13 (--configure):
 installed postgresql-client-13 package post-installation script subprocess was killed by signal (Aborted)
Setting up libz3-4:amd64 (4.8.10-1) ...
Setting up libllvm11:amd64 (1:11.0.1-2) ...
Setting up postgresql-common (225) ...
Adding user postgres to group ssl-cert

Creating config file /etc/postgresql-common/createcluster.conf with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /lib/systemd/system/postgresql.service.
dpkg: dependency problems prevent configuration of postgresql-13:
 postgresql-13 depends on postgresql-client-13; however:
  Package postgresql-client-13 is not configured yet.

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

dpkg: error processing package postgresql (--configure):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.31-13+deb11u2) ...
Errors were encountered while processing:
 postgresql-client-13
 postgresql-13
 postgresql
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

查看包 postgresql-client-13 以“iF”状态(配置失败)出现,其他失败的包以“iU”状态出现

dpkg -l | grep postgres

iU  postgresql                    13+225                         all          object-relational SQL database (supported version)
iU  postgresql-13                 13.5-0+deb11u1                 amd64        The World's Most Advanced Open Source Relational Database
iF  postgresql-client-13          13.5-0+deb11u1                 amd64        front-end programs for PostgreSQL 13
ii  postgresql-client-common      225                            all          manager for multiple PostgreSQL client versions
ii  postgresql-common             225                            all          PostgreSQL database-cluster manager

第二个字母 -> 当前包状态:

i ... installed
U ... unpacked
F ... half-configured (configuration failed for some reason)

在以下位置获取包状态 table: https://askubuntu.com/questions/18804/what-do-the-various-dpkg-flags-like-ii-rc-mean

我删除了所有 PostgreSQL 包和所有文件:sudo apt purge postgresql

之后我再次尝试安装postgresql-client-13,返回了上面的错误。 sudo apt install postgresql-client-13

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libllvm11 libz3-4
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  postgresql-client-common
Suggested packages:
  postgresql-13 postgresql-doc-13
The following NEW packages will be installed:
  postgresql-client-13 postgresql-client-common
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/1,603 kB of archives.
After this operation, 6,789 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package postgresql-client-common.
(Reading database ... 39655 files and directories currently installed.)
Preparing to unpack .../postgresql-client-common_225_all.deb ...
Unpacking postgresql-client-common (225) ...
Selecting previously unselected package postgresql-client-13.
Preparing to unpack .../postgresql-client-13_13.5-0+deb11u1_amd64.deb ...
Unpacking postgresql-client-13 (13.5-0+deb11u1) ...
Setting up postgresql-client-common (225) ...
Setting up postgresql-client-13 (13.5-0+deb11u1) ...
double free or corruption (!prev)
dpkg: error processing package postgresql-client-13 (--configure):
 installed postgresql-client-13 package post-installation script subprocess was killed by signal (Aborted)
Processing triggers for man-db (2.9.4-2) ...
Errors were encountered while processing:
 postgresql-client-13
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

问题与之前安装的 snoopy 包有关。

使用 sudo apt remove snoopy 卸载 snoopy,然后安装 PostgreSQL 或 postgresql-client-13。