I have followed this tutorial to remove PostgreSQL : https://www.squash.io/step-by-step-process-to-uninstall-postgresql-on-ubuntu/
Then I tried to reinstall it with sudo apt-get -y install postgresql.
The following error occurs:
sudo apt-get install -y postgresqlReading package lists... DoneBuilding dependency tree... DoneReading state information... DoneThe following package was automatically installed and is no longer required: postgresql-client-12Use 'sudo apt autoremove' to remove it.The following additional packages will be installed: postgresql-16 postgresql-commonSuggested packages: postgresql-docThe following NEW packages will be installed: postgresql postgresql-16 postgresql-common0 upgraded, 3 newly installed, 0 to remove and 2 not upgraded.3 not fully installed or removed.Need to get 18,2 MB/18,4 MB of archives.After this operation, 60,4 MB of additional disk space will be used.Get:1 https://apt.postgresql.org/pub/repos/apt jammy-pgdg/main amd64 postgresql-16 amd64 16.2-1.pgdg22.04+1 [18,1 MB]Get:2 https://apt.postgresql.org/pub/repos/apt jammy-pgdg/main amd64 postgresql all 16+257.pgdg22.04+1 [69,2 kB]Fetched 18,2 MB in 2s (9 434 kB/s) Preconfiguring packages ...Selecting previously unselected package postgresql-common.dpkg: warning: files list file for package 'postgresql-client-common' missing; assuming package has no files currently installeddpkg: warning: files list file for package 'postgresql-client-15' missing; assuming package has no files currently installed(Reading database ... 283693 files and directories currently installed.)Preparing to unpack .../postgresql-common_257.pgdg22.04+1_all.deb ...Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'Unpacking postgresql-common (257.pgdg22.04+1) ...Preparing to unpack .../postgresql-16_16.2-1.pgdg22.04+1_amd64.deb .../var/lib/dpkg/tmp.ci/preinst: 11: .: cannot open /usr/share/postgresql-common/maintscripts-functions: No such filedpkg: error processing archive /var/cache/apt/archives/postgresql-16_16.2-1.pgdg22.04+1_amd64.deb (--unpack): new postgresql-16 package pre-installation script subprocess returned error exit status 2Selecting previously unselected package postgresql.Preparing to unpack .../postgresql_16+257.pgdg22.04+1_all.deb ...Unpacking postgresql (16+257.pgdg22.04+1) ...Errors were encountered while processing: /var/cache/apt/archives/postgresql-16_16.2-1.pgdg22.04+1_amd64.debE: Sub-process /usr/bin/dpkg returned an error code (1)
I am on Ubuntu 22.04, trying to reinstall postgresql-16.
I tried
sudo apt-get clean,
sudo apt autoremove,
sudo apt-get install --reinstall postgresql-client-common.
sudo apt remove --purge postgresql-common
sudo apt-get -f install postgresql-client-common
sudo apt-get -f --fix-broken install postgresql-common
Nothing works until now.
Thanks a lot for the help !