Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql: Can't access to file « $libdir/postgis-2.1 » no such file or directory

I guess this is a known issue but since I have used a script that removed my postgresql-9.4-postgis-2.1, I'm now unable to get rid of this SQL error under Debian.

Can't access to file « $libdir/postgis-2.1 » no such file or directory

I've done the following:

- Remove new unwanted postgresql-9.5-postgis-2.2 package installed
- Reinstalling postgresql-9.4-postgis-2.1, postgresql-9.4-postgis-scripts and postgis
- Using SQL: ALTER EXTENSION postgis UPDATE TO '2.1.4' --under postgres user
- Using SQL: ALTER EXTENSION postgis_topology UPDATE TO '2.1.4' --under postgres user

And SELECT * FROM pg_available_extensions; returns

[...]
postgis 2.1.4   2.1.4   PostGIS geometry, geography, and raster spatial types and functions.

But still this message when accessing object like tables that uses geometry type.

Any idea?

like image 511
AnomalySmith Avatar asked Apr 06 '16 07:04

AnomalySmith


2 Answers

First run (as postgres administrator) in the database that needs it (\c your-database-name):

ALTER EXTENSION postgis UPDATE;

If this returns successfully, then check what version you have

SELECT PostGIS_Full_Version();

If however, the server returns that it cannot find the extension postgis, then run

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
ALTER EXTENSION postgis UPDATE;

and again check by running

SELECT PostGIS_Full_Version();
like image 66
David Hine Avatar answered Oct 24 '22 08:10

David Hine


Finally "solve" the issue compiling from source postgis 2.2.2 (that also requires gdal, proj4 and geos) and then issuing

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

since DROP EXTENSION postgis; tells me postgis wasn't present anymore.

And finally:

ALTER EXTENSION postgis UPDATE TO '2.2.2';
ALTER EXTENSION postgis_topology UPDATE TO '2.2.2';

Got access again to my geom data and functions from PostgreSQL 9.4. It seems that compiling from source updated correctly the variable path for postgresql and installed /usr/lib/postgresql/9.4/lib/postgis-2.2.so that wasn't present anymore (for postgis-2.1.so as well), even with (re)installing from apt-get.

Hope this will help.

like image 7
AnomalySmith Avatar answered Oct 24 '22 09:10

AnomalySmith