Thread: Unable to run psql on 9.5 after broken 12 remove
I have a production server running pg9.5 seamlessly. Yesterday I decided to install libpq to have some crypto functions. Unexpectedly, it installed postgresql 12 and its libpq. I don't need pg 12, so I decided to remove it. It did not went well root@datastore-1:/home/user# apt-get --purge remove postgresql-client-12 Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libuuid-perl Use 'apt-get autoremove' to remove it. The following packages will be REMOVED: postgresql-12* postgresql-client-12* postgresql-contrib* 0 upgraded, 0 newly installed, 3 to remove and 89 not upgraded. 1 not fully installed or removed. After this operation, 30.9 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 32065 files and directories currently installed.) Removing postgresql-contrib (12+215.pgdg80+1) ... Removing postgresql-12 (12.3-1.pgdg80+1) ... update-alternatives: using /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode Purging configuration files for postgresql-12 (12.3-1.pgdg80+1) ... Removing postgresql-client-12 (12.3-1.pgdg80+1) ... update-alternatives: using /usr/share/postgresql/9.5/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode Processing triggers for postgresql-common (215.pgdg80+1) ... Building PostgreSQL dictionaries from installed myspell/hunspell packages... Removing obsolete dictionary files: Setting up python3.4 (3.4.2-1+deb8u3) ... File "/usr/lib/python3.4/http/client.py", line 1014 raise InvalidURL(f"URL can't contain control characters. {url!r} " ^ SyntaxError: invalid syntax dpkg: error processing package python3.4 (--configure): subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: python3.4 E: Sub-process /usr/bin/dpkg returned an error code (1) After this, the package is not anymore on the installed list and I'm not able to issue the psql command: root@datastore-1:/home/user# sudo -u postgres psql Error: PostgreSQL version 12 is not installed How can I repair this? Thanks in advance Moreno.
After upgrading python the InvalidUrl is gone, but I still can't run psql Output of pg_lsclusters, if needed root@datastore-1:/usr/share/postgresql-common# pg_lsclusters Ver Cluster Port Status Owner Data directory Log file 9.5 main 6543 online postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log 12 main 5432 down,binaries_missing <unknown> /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log I followed https://askubuntu.com/questions/1223270/psql-command-error-postgresql-version-12-is-not-installed with no luck, apt-purge simply states that pg12 is not installed. Il 03/07/2020 10:37, Moreno Andreo ha scritto: > I have a production server running pg9.5 seamlessly. > Yesterday I decided to install libpq to have some crypto functions. > Unexpectedly, it installed postgresql 12 and its libpq. > I don't need pg 12, so I decided to remove it. > It did not went well > > root@datastore-1:/home/user# apt-get --purge remove postgresql-client-12 > Reading package lists... Done > Building dependency tree > Reading state information... Done > The following package was automatically installed and is no longer > required: > libuuid-perl > Use 'apt-get autoremove' to remove it. > The following packages will be REMOVED: > postgresql-12* postgresql-client-12* postgresql-contrib* > 0 upgraded, 0 newly installed, 3 to remove and 89 not upgraded. > 1 not fully installed or removed. > After this operation, 30.9 MB disk space will be freed. > Do you want to continue? [Y/n] y > (Reading database ... 32065 files and directories currently installed.) > Removing postgresql-contrib (12+215.pgdg80+1) ... > Removing postgresql-12 (12.3-1.pgdg80+1) ... > update-alternatives: using > /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide > /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode > Purging configuration files for postgresql-12 (12.3-1.pgdg80+1) ... > Removing postgresql-client-12 (12.3-1.pgdg80+1) ... > update-alternatives: using > /usr/share/postgresql/9.5/man/man1/psql.1.gz to provide > /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode > Processing triggers for postgresql-common (215.pgdg80+1) ... > Building PostgreSQL dictionaries from installed myspell/hunspell > packages... > Removing obsolete dictionary files: > Setting up python3.4 (3.4.2-1+deb8u3) ... > File "/usr/lib/python3.4/http/client.py", line 1014 > raise InvalidURL(f"URL can't contain control characters. {url!r} " > ^ > SyntaxError: invalid syntax > dpkg: error processing package python3.4 (--configure): > subprocess installed post-installation script returned error exit > status 1 > Errors were encountered while processing: > python3.4 > E: Sub-process /usr/bin/dpkg returned an error code (1) > > After this, the package is not anymore on the installed list and I'm > not able to issue the psql command: > > root@datastore-1:/home/user# sudo -u postgres psql > Error: PostgreSQL version 12 is not installed > > How can I repair this? > Thanks in advance > Moreno. > > >
On 7/3/20 1:54 AM, Moreno Andreo wrote: > After upgrading python the InvalidUrl is gone, but I still can't run psql > > Output of pg_lsclusters, if needed > root@datastore-1:/usr/share/postgresql-common# pg_lsclusters > Ver Cluster Port Status Owner Data > directory Log file > 9.5 main 6543 online postgres > /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log > 12 main 5432 down,binaries_missing <unknown> > /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log > > I followed > https://askubuntu.com/questions/1223270/psql-command-error-postgresql-version-12-is-not-installed > > with no luck, apt-purge simply states that pg12 is not installed. Looks like the cluster was not removed from the pgcommon setup. This would explain why you can't run psql. By default pgcommon looks for the version of psql connected with the most recent version of Postgres it knows about, in this case 12. Unfortunately that binary no longer exists. You still have psql. Do: /usr/lib/postgresql/9.5/bin/psql --help To avoid having to do that try: sudo pg_dropcluster 12 main > > > Il 03/07/2020 10:37, Moreno Andreo ha scritto: >> I have a production server running pg9.5 seamlessly. >> Yesterday I decided to install libpq to have some crypto functions. >> Unexpectedly, it installed postgresql 12 and its libpq. >> I don't need pg 12, so I decided to remove it. >> It did not went well >> >> root@datastore-1:/home/user# apt-get --purge remove postgresql-client-12 >> Reading package lists... Done >> Building dependency tree >> Reading state information... Done >> The following package was automatically installed and is no longer >> required: >> libuuid-perl >> Use 'apt-get autoremove' to remove it. >> The following packages will be REMOVED: >> postgresql-12* postgresql-client-12* postgresql-contrib* >> 0 upgraded, 0 newly installed, 3 to remove and 89 not upgraded. >> 1 not fully installed or removed. >> After this operation, 30.9 MB disk space will be freed. >> Do you want to continue? [Y/n] y >> (Reading database ... 32065 files and directories currently installed.) >> Removing postgresql-contrib (12+215.pgdg80+1) ... >> Removing postgresql-12 (12.3-1.pgdg80+1) ... >> update-alternatives: using >> /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide >> /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode >> Purging configuration files for postgresql-12 (12.3-1.pgdg80+1) ... >> Removing postgresql-client-12 (12.3-1.pgdg80+1) ... >> update-alternatives: using >> /usr/share/postgresql/9.5/man/man1/psql.1.gz to provide >> /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode >> Processing triggers for postgresql-common (215.pgdg80+1) ... >> Building PostgreSQL dictionaries from installed myspell/hunspell >> packages... >> Removing obsolete dictionary files: >> Setting up python3.4 (3.4.2-1+deb8u3) ... >> File "/usr/lib/python3.4/http/client.py", line 1014 >> raise InvalidURL(f"URL can't contain control characters. {url!r} " >> ^ >> SyntaxError: invalid syntax >> dpkg: error processing package python3.4 (--configure): >> subprocess installed post-installation script returned error exit >> status 1 >> Errors were encountered while processing: >> python3.4 >> E: Sub-process /usr/bin/dpkg returned an error code (1) >> >> After this, the package is not anymore on the installed list and I'm >> not able to issue the psql command: >> >> root@datastore-1:/home/user# sudo -u postgres psql >> Error: PostgreSQL version 12 is not installed >> >> How can I repair this? >> Thanks in advance >> Moreno. >> >> >> > > > > -- Adrian Klaver adrian.klaver@aklaver.com
Il 03/07/2020 16:51, Adrian Klaver ha scritto: > On 7/3/20 1:54 AM, Moreno Andreo wrote: > > Looks like the cluster was not removed from the pgcommon setup. This > would explain why you can't run psql. By default pgcommon looks for > the version of psql connected with the most recent version of Postgres > it knows about, in this case 12. Unfortunately that binary no longer > exists. You still have psql. Do: > > /usr/lib/postgresql/9.5/bin/psql --help OK, it confirms that 9.5 client is still ok > > To avoid having to do that try: > > sudo pg_dropcluster 12 main This reported a warning root@datastore-1:/home/user# pg_dropcluster 12 main Warning: corrupted cluster: data directory does not exist ... but it did its job root@datastore-1:/home/user# sudo -u postgres psql psql (9.5.6) Type "help" for help. postgres=# \q Thanks, you saved my day again! Moreno. > >> >> >> Il 03/07/2020 10:37, Moreno Andreo ha scritto: >>> I have a production server running pg9.5 seamlessly. >>> Yesterday I decided to install libpq to have some crypto functions. >>> Unexpectedly, it installed postgresql 12 and its libpq. >>> I don't need pg 12, so I decided to remove it. >>> It did not went well >>> >>> root@datastore-1:/home/user# apt-get --purge remove >>> postgresql-client-12 >>> Reading package lists... Done >>> Building dependency tree >>> Reading state information... Done >>> The following package was automatically installed and is no longer >>> required: >>> libuuid-perl >>> Use 'apt-get autoremove' to remove it. >>> The following packages will be REMOVED: >>> postgresql-12* postgresql-client-12* postgresql-contrib* >>> 0 upgraded, 0 newly installed, 3 to remove and 89 not upgraded. >>> 1 not fully installed or removed. >>> After this operation, 30.9 MB disk space will be freed. >>> Do you want to continue? [Y/n] y >>> (Reading database ... 32065 files and directories currently installed.) >>> Removing postgresql-contrib (12+215.pgdg80+1) ... >>> Removing postgresql-12 (12.3-1.pgdg80+1) ... >>> update-alternatives: using >>> /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide >>> /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode >>> Purging configuration files for postgresql-12 (12.3-1.pgdg80+1) ... >>> Removing postgresql-client-12 (12.3-1.pgdg80+1) ... >>> update-alternatives: using >>> /usr/share/postgresql/9.5/man/man1/psql.1.gz to provide >>> /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode >>> Processing triggers for postgresql-common (215.pgdg80+1) ... >>> Building PostgreSQL dictionaries from installed myspell/hunspell >>> packages... >>> Removing obsolete dictionary files: >>> Setting up python3.4 (3.4.2-1+deb8u3) ... >>> File "/usr/lib/python3.4/http/client.py", line 1014 >>> raise InvalidURL(f"URL can't contain control characters. {url!r} " >>> ^ >>> SyntaxError: invalid syntax >>> dpkg: error processing package python3.4 (--configure): >>> subprocess installed post-installation script returned error exit >>> status 1 >>> Errors were encountered while processing: >>> python3.4 >>> E: Sub-process /usr/bin/dpkg returned an error code (1) >>> >>> After this, the package is not anymore on the installed list and I'm >>> not able to issue the psql command: >>> >>> root@datastore-1:/home/user# sudo -u postgres psql >>> Error: PostgreSQL version 12 is not installed >>> >>> How can I repair this? >>> Thanks in advance >>> Moreno. >>> >>> >>> >> >> >> >> > >
On 7/3/20 8:15 AM, Moreno Andreo wrote: > Il 03/07/2020 16:51, Adrian Klaver ha scritto: >> On 7/3/20 1:54 AM, Moreno Andreo wrote: >> >> Looks like the cluster was not removed from the pgcommon setup. This >> would explain why you can't run psql. By default pgcommon looks for >> the version of psql connected with the most recent version of Postgres >> it knows about, in this case 12. Unfortunately that binary no longer >> exists. You still have psql. Do: >> >> /usr/lib/postgresql/9.5/bin/psql --help > OK, it confirms that 9.5 client is still ok >> >> To avoid having to do that try: >> >> sudo pg_dropcluster 12 main > This reported a warning Yeah, I'm guessing the original uninstall clean up process went off the rails here: " Processing triggers for postgresql-common (215.pgdg80+1) ... Building PostgreSQL dictionaries from installed myspell/hunspell packages... Removing obsolete dictionary files: Setting up python3.4 (3.4.2-1+deb8u3) ... File "/usr/lib/python3.4/http/client.py", line 1014 raise InvalidURL(f"URL can't contain control characters. {url!r} " ^ SyntaxError: invalid syntax dpkg: error processing package python3.4 (--configure): " The below just finished what the above started. > > root@datastore-1:/home/user# pg_dropcluster 12 main > Warning: corrupted cluster: data directory does not exist > > ... but it did its job > > root@datastore-1:/home/user# sudo -u postgres psql > psql (9.5.6) > Type "help" for help. > > postgres=# \q > > > Thanks, you saved my day again! > > Moreno. > >> >>> >>> -- Adrian Klaver adrian.klaver@aklaver.com