mapnik / node-mapnik

Bindings to mapnik for node.js
http://mapnik.org/documentation/node-mapnik
BSD 3-Clause "New" or "Revised" License
531 stars 165 forks source link

postgis plugin not loaded anymore #984

Closed yohanboniface closed 2 years ago

yohanboniface commented 2 years ago

Hi there,

While running kosmtik, I got this error:

[Error: Could not create datasource for type: 'postgis' (searched for datasource plugins in '/home/ybon/Code/js/kosmtik/node_modules/mapnik/lib/binding/lib/mapnik/input')  encountered during parsing of layer 'landuse_gen0' in Layer]

There is a postgis.input in the directory printed in the error message:

leonardo:~/C/m/riverboat (master !=) ll /home/ybon/Code/js/kosmtik/node_modules/mapnik/lib/binding/lib/mapnik/input                                                                   2s 989ms
total 29M
41648608 4,0K drwxr-xr-x 2 ybon ybon 4,0K 17 juin  11:36 ./
41648606 4,0K drwxr-xr-x 4 ybon ybon 4,0K 17 juin  11:36 ../
41624914 972K -rwxr-xr-x 1 ybon ybon 971K 28 oct.   2021 csv.input*
41624915  12M -rwxr-xr-x 1 ybon ybon  12M 28 oct.   2021 gdal.input*
41624916 244K -rwxr-xr-x 1 ybon ybon 242K 28 oct.   2021 geobuf.input*
41624917 1,1M -rwxr-xr-x 1 ybon ybon 1,1M 28 oct.   2021 geojson.input*
41624918  12M -rwxr-xr-x 1 ybon ybon  12M 28 oct.   2021 ogr.input*
41624919 584K -rwxr-xr-x 1 ybon ybon 581K 28 oct.   2021 pgraster.input*
41624920 560K -rwxr-xr-x 1 ybon ybon 557K 28 oct.   2021 postgis.input*
41624921 168K -rwxr-xr-x 1 ybon ybon 167K 28 oct.   2021 raster.input*
41624922 164K -rwxr-xr-x 1 ybon ybon 162K 28 oct.   2021 shape.input*
41624923 1,6M -rwxr-xr-x 1 ybon ybon 1,6M 28 oct.   2021 sqlite.input*
41624924 540K -rwxr-xr-x 1 ybon ybon 540K 28 oct.   2021 topojson.input*

So to try to understand what's going on, I've tried to run node-mapnik tests, and here is what I see on the console:

Mapnik LOG> 2022-06-18 10:47:50: Problem loading plugin library: /home/ybon/Code/js/node-mapnik/lib/binding/lib/mapnik/input/postgis.input (dlopen failed - plugin likely has an unsatisfied dependency or incompatible ABI)

I did not change anything as far as I can remember on my kosmtik install since last time I used it (successfully), but time has passed, so I may have updated some system package that breaks something for mapnik, but with those logs I don't how where to investigate. I then tried to reinstall kosmtik from scratch, but I end up with the same error.

Any clue how to debug this ?

Thanks a log in advance :)

Yohan

springmeyer commented 2 years ago

Try this:

$ python
>>> import ctypes
>>> ctypes.CDLL('/home/ybon/Code/js/node-mapnik/lib/binding/lib/mapnik/input/postgis.input')

I pulled that from https://github.com/mapnik/node-mapnik/wiki/Troubleshooting#the-specified-module-cannot-be-found. It might need updated to latest python in case something changed with python 3. Either way, the idea here is that python has better error reporting and should show what is actually wrong with the dynamic library/loadable module on your system. My hunch is the same as yours: updating some system package impacted the plugin. When compiling the node-mapnik libraries we made every effort to statically link as many libraries as possible, so that there would be no breakages if the system changed. But the postgis plugin depends on SSL, which requires openssl, which was too much to statically link.

yohanboniface commented 2 years ago

Thanks Dane for the tip!

In [2]: ctypes.CDLL('/home/ybon/Code/js/node-mapnik/lib/binding/lib/mapnik/input/postgis.input')
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 ctypes.CDLL('/home/ybon/Code/js/node-mapnik/lib/binding/lib/mapnik/input/postgis.input')

File /usr/lib/python3.10/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    371 self._FuncPtr = _FuncPtr
    373 if handle is None:
--> 374     self._handle = _dlopen(self._name, mode)
    375 else:
    376     self._handle = handle

OSError: libcrypt.so.1: cannot open shared object file: No such file or directory

So I installed libxcrypt-compat (I'm on arch), and it worked again, yay :)

One more beer I own you, ha ha! :)