Could not access file "$libdir/plpgsql": No such file or directory

Viewed 29906

I'm at a loss, I'm having issues creating a stored proc in my local Postgres server (postgres.app, Mac OS X 10.7), as so

$ psql
psql (9.3.0)
Type "help" for help.

dchaston=# CREATE OR REPLACE FUNCTION table_update()
dchaston-# RETURNS TRIGGER AS $$
dchaston$# BEGIN
dchaston$#   NEW.last_edit = now();
dchaston$#   RETURN NEW;
dchaston$# END;
dchaston$# $$ language 'plpgsql';
ERROR:  could not access file "$libdir/plpgsql": No such file or directory

I've checked the following:

Languages installed:

dchaston=# select * from pg_language;
lanname  | lanowner | lanispl | lanpltrusted | lanplcallfoid | laninline | lanvalidator | lanacl
---------+----------+---------+--------------+---------------+-----------+--------------+--------
internal |       10 | f       | f            |             0 |         0 |         2246 | 
c        |       10 | f       | f            |             0 |         0 |         2247 | 
sql      |       10 | f       | t            |             0 |         0 |         2248 | 
plpgsql  |       10 | t       | t            |         12019 |     12020 |        12021 | 
(4 rows)

lib directory (and pkglibdir just in case):

$ pg_config --libdir
/Applications/Postgres.app/Contents/MacOS/lib
$ pg_config --pkglibdir
/Applications/Postgres.app/Contents/MacOS/lib

File present:

$ cd /Applications/Postgres.app/Contents/MacOS/lib; ls plpg*
plpgsql.so

DLSUFFIX set correctly:

lib/pgxs/src/Makefile.shlib:135:    DLSUFFIX        = .so

Have tried uninstalling and reinstalling, but made no difference. Any ideas?

3 Answers

This one is related to the accepted answer.

I started getting the problem with libdir on MacOS Catalina 10.15.7 while doing the brew update as the brew update failed in between and I noticed that Postgresql was one of the many packages that it was trying to update and the above answer provided a good hint about multiple installations.

I verified that there weren't any additional versions of postgresql installed on my system. So a simple restart of the service did the trick for me: brew services restart postgresql@10

I use FreeBSD and found a simple way to solve the problem, just copied the library from another server and pasted it into /usr/local/lib/postgresql/, which is the way $libdir. Although the versions of PostgreSQL are different, everything is working and I had no problems again.

Related