1

I am aware there are a few similar questions to this one, such as here and here. My problem is however a bit different.

I've recently upgraded my Ubuntu to 20.04 and there only PostgreSQL 12.3 and PostGIS 3.0 are fetchable on the official repo. This means that getting earlier versions is not very straightforward.

Thinking that the easiest way forward would be to also upgrade my Django database to the latest version above, I decided to try that. To my surprise, I keep getting the following error:

could not access file "$libdir/postgis-2.4": No such file or directory

This happened first in my Django app but naturally also when accessing the database via psql directly. I then proceeded to drop the database and create it again, as luckily the data I had there was still only test stuff. As soon as I try to create the PostGIS extension to it, guess which error I get...

mydb=# CREATE EXTENSION postgis;
ERROR:  could not access file "$libdir/postgis-2.4": No such file or directory

My conclusion is that it doesn't seem to be a problem directly related to the upgrade of postgis to 3.0, as I'm not even able to create the extension. Also, I don't understand why it tries to access the 2.4 version as it is a brand new database. Restarting the PostgreSQ service or even the computer wasn't of any help.

How can I approach this problem?

  • have you seen this post? – JGH Jun 12 at 19:25
  • I hadn't. Unfortunately it doesn't help in my case. postgresql-12-postgis-2.5 is not reference in my apt, only postgresql-12-postgis-3, which is already installed: postgresql-12-postgis-3 is already the newest version (3.0.0+dfsg-6ubuntu4). – edwillys Jun 12 at 19:36
1

I ended up fixing the issue. The problem seems to be due to the fact that there were still many 'residual' folders from older versions of postgresql still present on

/etc/postgresql/
/usr/postgresql/
/usr/postgresql-common/

even after removing them with apt remove. The result is that after reinstalling postgresql and postgresql-common, the binary psql was linked to and older version of it, which itself was linked to an older version of postgis (in my case 2.4), that was not present anymore. I'm still not sure whether this was a problem with the upgrade on Ubuntu or the upgrade of postgresql.

The solution is basically really remove all of postgresql, postgis and postgresql-common packages before re-installing them with apt install. I took the hard path of manually removing the folders myself, which in turn led to an incredible mess of packaging managers not being able to install, clean or remove them anymore, as they were broke. I definitely do not recommend this approach. Instead, it should be possible to properly force the removal of packages:

  1. Find all of the relevant postgresql and postgis packages that are installed:
    dpkg -l | grep postgis
    dpkg -l | grep postgresql
  1. Force delete them with
    sudo dpkg --remove --force-all <package_name>
  1. Reinstall them with apt install
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.