我尝试在我的 ubuntu 21.10 客户端上安装 postgres。
sudo apt install postgresql postgresql-contrib
这导致了警告,但我还是决定安装它。这不是一件聪明的事情,因为这会导致依赖性问题(见下文)并最终导致包损坏。
我试过:
sudo dpkg --configure -a
sudo apt -f install
sudo apt update
sudo apt autoremove
还有很多。现在可以归结为 postgresql-client-13 需要某个文件,但找不到它并终止卸载(或安装新的 postgresql 版本)。有谁知道如何从这种情况下卸载 postgresql 并按顺序获取 apt 吗?
$ sudo apt remove --purge postgresql
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'postgresql' is not installed, so not removed
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.
Setting up postgresql-client-13 (13.5-0ubuntu0.21.10.1) ...
/var/lib/dpkg/info/postgresql-client-13.postinst: 7: .: cannot open /usr/share/postgresql-common/mai
ntscripts-functions: No such file
dpkg: error processing package postgresql-client-13 (--configure):
installed postgresql-client-13 package post-installation script subprocess returned error exit stat
us 2
Errors were encountered while processing:
postgresql-client-13
E: Sub-process /usr/bin/dpkg returned an error code (1)
原始安装:
$ sudo apt install postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
postgresql-13 postgresql-client-13
Suggested packages:
postgresql-doc postgresql-doc-13
The following NEW packages will be installed:
postgresql postgresql-13 postgresql-client-13 postgresql-contrib
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 16.2 MB of archives.
After this operation, 46.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://nl.archive.ubuntu.com/ubuntu impish-updates/main amd64 postgresql-client-13 amd64 13.5-0ubuntu0.21.10.1 [1,145 kB]
Get:2 http://nl.archive.ubuntu.com/ubuntu impish-updates/main amd64 postgresql-13 amd64 13.5-0ubuntu0.21.10.1 [15.0 MB]
Get:3 http://nl.archive.ubuntu.com/ubuntu impish/main amd64 postgresql all 13+226 [4,624 B]
Get:4 http://nl.archive.ubuntu.com/ubuntu impish/main amd64 postgresql-contrib all 13+226 [4,636 B]
Fetched 16.2 MB in 5s (3,223 kB/s)
Preconfiguring packages ...
Selecting previously unselected package postgresql-client-13.
dpkg: warning: files list file for package 'postgresql-14' missing; assuming package has no files cu
rrently installed
dpkg: warning: files list file for package 'postgresql-client-common' missing; assuming package has
no files currently installed
dpkg: warning: files list file for package 'postgresql-client-14' missing; assuming package has no f
iles currently installed
dpkg: warning: files list file for package 'postgresql-common' missing; assuming package has no file
s currently installed
(Reading database ... 444111 files and directories currently installed.)
Preparing to unpack .../postgresql-client-13_13.5-0ubuntu0.21.10.1_amd64.deb ...
Unpacking postgresql-client-13 (13.5-0ubuntu0.21.10.1) ...
Selecting previously unselected package postgresql-13.
Preparing to unpack .../postgresql-13_13.5-0ubuntu0.21.10.1_amd64.deb ...
Unpacking postgresql-13 (13.5-0ubuntu0.21.10.1) ...
Selecting previously unselected package postgresql.
Preparing to unpack .../postgresql_13+226_all.deb ...
Unpacking postgresql (13+226) ...
Selecting previously unselected package postgresql-contrib.
Preparing to unpack .../postgresql-contrib_13+226_all.deb ...
Unpacking postgresql-contrib (13+226) ...
Setting up postgresql-client-13 (13.5-0ubuntu0.21.10.1) ...
/var/lib/dpkg/info/postgresql-client-13.postinst: 7: .: cannot open /usr/share/postgresql-common/mai
ntscripts-functions: No such file
dpkg: error processing package postgresql-client-13 (--configure):
installed postgresql-client-13 package post-installation script subprocess returned error exit stat
us 2
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
dpkg: dependency problems prevent configuration of postgresql-contrib:
postgresql-contrib depends on postgresql-contrib-13; however:
Package postgresql-contrib-13 is not installed.
Package postgresql-13 which provides postgresql-contrib-13 is not configured yet.
dpkg: error processing package postgresql-contrib (--configure):
dependency problems - leaving unconfigured
Processing triggers for postgresql-comNo apport report written because the error message indicates i
ts a followup error from a previous failure.
No apport report written because the error message indic
ates its a followup error from a previous failure.
No apport report written because MaxReports is rea
ched already
mon (232.pgdg21.10+1) ...
Errors were encountered while processing:
postgresql-client-13
postgresql-13
postgresql
postgresql-contrib
E: Sub-process /usr/bin/dpkg returned an error code (1)
更新
我尝试了@PersianGulf 的建议:它做要求删除 postgresql-client-13 但仍然无法删除它。
$ sudo apt --force-yes remove postgresql-client-13
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
postgresql-client-13
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 3,609 kB disk space will be freed.
W: --force-yes is deprecated, use one of the options starting with --allow instead.
Do you want to continue? [Y/n]
dpkg: warning: files list file for package 'postgresql-client-common' missing; assuming package has
no files currently installed
dpkg: warning: files list file for package 'postgresql-client-14' missing; assuming package has no f
iles currently installed
(Reading database ... 446025 files and directories currently installed.)
Removing postgresql-client-13 (13.5-0ubuntu0.21.10.1) ...
/var/lib/dpkg/info/postgresql-client-13.prerm: 11: remove_client_version: not found
dpkg: error processing package postgresql-client-13 (--remove):
installed postgresql-client-13 package pre-removal script subprocess returned error exit status 127
dpkg: too many errors, stopping
Errors were encountered while processing:
postgresql-client-13
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
损坏是由于 的问题造成的postgresql-client-common
。该软件包需要能够卸载其他软件包,但至少缺少其某些内容,导致
/var/lib/dpkg/info/postgresql-client-13.postinst: 7: .: cannot open /usr/share/postgresql-common/maintscripts-functions: No such file
dpkg
对包的状态相当不满意:
dpkg: warning: files list file for package 'postgresql-client-common' missing; assuming package has no files currently installed
要解决问题,您需要强制重新安装此软件包,也许postgreql-common
:
sudo apt reinstall postgreql-client-common
完成后,您应该能够删除 PostgreSQL 13 软件包。