0

I upgraded Ubuntu from 15.01 to 16.04 and PostGIS is broken. Below are the errors:

psql (9.5.2)
Type "help" for help.

osm=# select version();
version                                           
-------------------------------------------------------------------------------------------------
 PostgreSQL 9.5.2 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
(1 row)

osm=# \dx
                                      List of installed extensions<br>
   Name    | Version |   Schema   |                             Description                             
-----------+---------+------------+---------------------------------------------------------------------
 hstore    | 1.3     | public     | data type for storing sets of (key, value) pairs
 pgrouting | 2.1.0   | public     | pgRouting Extension
 plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis   | 2.2.2   | public     | PostGIS geometry, geography, and raster spatial types and functions
(4 rows)

osm=# select postgis_full_version();
ERROR:  could not load library "/usr/lib/postgresql/9.5/lib/postgis-2.2.so": /usr/lib/postgresql/9.5/lib/postgis-2.2.so: undefined symbol: lwgeom_sfcgal_version
CONTEXT:  SQL statement "SELECT postgis_lib_version()"
PL/pgSQL function postgis_full_version() line 22 at SQL statement

This database had PostGIS working before the upgrade. I tried create extension postgis; on a new database and got the same error. I also tried to remove and install PostGIS again but to no avail.

alphabetasoup
  • 8,718
  • 4
  • 38
  • 78
Huanchun Ye
  • 73
  • 1
  • 5
  • The error suggests that you don't have lwgeom installed. Can you check if it is, and if not, try installing that (sudo apt-get install liblwgeom)? You may need to restart postgres afterwards. – BradHards May 07 '16 at 00:25
  • 1
    I rebuilt postgis-2.2.2 from source and the problem is resolved, so evidently the binary in Ubuntu Xenial repo is somehow broken. The build steps are all default:
    ./configure
    make
    sudo make install
    

    Before this, I tried to install liblwgeom-2.2.5 and liblwgeom-dev but they did not help (2.2.5 was already present).

    – Huanchun Ye May 07 '16 at 00:53
  • Perhaps you should post that as the answer. – BradHards May 07 '16 at 01:45

3 Answers3

5

Rebuilding from source worked for me also.

The problem wasn't realy system upgrade. Simply, creating extensions such as postgis_topology or postgis_tiger_geocoder threw exactly the same error.

I advise also restarting postgresql service after rebuilding, just in case. Or better :
-stop the service; -rebuild; -start again the service;

And it might be worth adding sudo ldconfig at the end :

./configure
make

in case you want to test the build prior installing :

make test

and then

sudo make install
sudo ldconfig
zer0mode
  • 151
  • 1
  • 3
2

Rebuilding postgis-2.2.2 from the source solved the problem, using the default build steps:

./configure
make
make install

Huanchun Ye
  • 73
  • 1
  • 5
0

This solved this issue for me (it says 14.04 but solved for 16.04):

PostGIS non functional on Ubuntu 14.04

victor
  • 1