pramsey / pgsql-postal

PostgreSQL binding for libpostal
MIT License
138 stars 20 forks source link

Postal installation fails on Postgres 13 DB server #16

Closed FrederickCoene closed 3 years ago

FrederickCoene commented 3 years ago

Hi,

I tried to install postal on a Postgres 13 DB server (PostgreSQL 13.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), 64-bit).

I installed libpostal and executed the following commands: make make install

Output: `# make gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -I/usr/local/include -I. -I./ -I/usr/pgsql-13/include/server -I/usr/pgsql-13/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o postal.o postal.c gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -shared -o postal.so postal.o -L/usr/pgsql-13/lib -Wl,--as-needed -L/usr/lib64 -L/usr/lib64 -Wl,--as-needed -Wl,-rpath,'/usr/pgsql-13/lib',--enable-new-dtags -L/usr/local/lib -lpostal /usr/bin/clang -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -O2 -I/usr/local/include -I. -I./ -I/usr/pgsql-13/include/server -I/usr/pgsql-13/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -flto=thin -emit-llvm -c -o postal.bc postal.c

make install

/usr/bin/mkdir -p '/usr/pgsql-13/lib' /usr/bin/mkdir -p '/usr/pgsql-13/share/extension' /usr/bin/mkdir -p '/usr/pgsql-13/share/extension' /usr/bin/install -c -m 755 postal.so '/usr/pgsql-13/lib/postal.so' /usr/bin/install -c -m 644 .//postal.control '/usr/pgsql-13/share/extension/' /usr/bin/install -c -m 644 .//postal--1.0.sql '/usr/pgsql-13/share/extension/' /usr/bin/mkdir -p '/usr/pgsql-13/lib/bitcode/postal' /usr/bin/mkdir -p '/usr/pgsql-13/lib/bitcode'/postal/ /usr/bin/install -c -m 644 postal.bc '/usr/pgsql-13/lib/bitcode'/postal/./ cd '/usr/pgsql-13/lib/bitcode' && /usr/bin/llvm-lto -thinlto -thinlto-action=thinlink -o postal.index.bc postal/postal.bc`

When I try to add the extension in the DB: create extension postal;

I get the following error log (postgres logs): ERR Error loading transliteration module, dir=(null) at libpostal_setup_datadir (libpostal.c:290) errno: Permission denied 2021-05-17 20:14:30 CEST [636855]: postgres postgres DBeaver 7.3.5 - SQLEditor <Script-144.sql> 127.0.0.1ERROR: Failed to initialize libpostal. 2021-05-17 20:14:30 CEST [636855]: postgres postgres DBeaver 7.3.5 - SQLEditor <Script-144.sql> 127.0.0.1STATEMENT: create extension postal

Why is the dir = null? Do I need to initialize an environment variable?

I tested libpostal locally and it works without a problem: `libpostal]# ./src/address_parser Loading models...

Welcome to libpostal's address parser.

Type in any address to parse and print the result.

Special commands: .exit to quit the program

dummystreet England

Result:

{ "city": "dummystreet", "state": "england" }`

pramsey commented 3 years ago

Looks like a permissions issue. The account your database is running under (probably 'postgres') perhaps does not have read access to the libpostal files it needs. Go through and make sure all directories have global read and all files are global read in the libpostal install location.

FrederickCoene commented 3 years ago

I just re-installed the package and now it works (without additional changes)... I re-installed it 5 times yesterday without any luck...

Installation: ` yum install curl autoconf automake libtool pkgconfig git clone https://github.com/openvenues/libpostal cd libpostal ./bootstrap.sh ./configure --datadir=/opt/libpostal make -j4 sudo make install sudo ldconfig cd .. git clone https://github.com/pramsey/pgsql-postal.git cd pgsql-postal/

add pgsql-13/bin folder to path (server specific):

export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/pgsql-13/bin/ make make install `