# psql: error while loading shared libraries: libpq.so.rh-postgresql10-5

Problem

Unable to get Postgres 10 psql to run, so I am unable to query it. Error being thrown is error while loading shared libraries: libpq.so.rh-postgresql10-5

Diagnose

As the postgres user, there psql is not found automatically - so you will either need to use its full path, or cd /opt/rh/rh-postgresql10/root/usr/bin before running psql.

[root@rhv-m ~]# su - postgres
Last login: Wed Jul  7 12:53:18 BST 2021 on pts/0
-bash-4.2$ cd /opt/rh/rh-postgresql10/root/usr/bin
-bash-4.2$ ./psql -d engine
./psql: error while loading shared libraries: libpq.so.rh-postgresql10-5: cannot open shared object file: No such file or directory

Checking that libpq.so.rh-postgresql10-5 exists and where:

find / -name libpq.so.rh-postgresql10-5
...
/opt/rh/rh-postgresql10/root/usr/lib64/libpq.so.rh-postgresql10-5

So this is an issue with configuration and or setup.

Solution

State the path to the library before running the psql binary thus LD_LIBRARY_PATH

-bash-4.2$ cd /opt/rh/rh-postgresql10/root/usr/bin
-bash-4.2$ LD_LIBRARY_PATH=/opt/rh/rh-postgresql10/root/usr/lib64/ ./psql -d engine
psql (10.12)
Type "help" for help.

engine=# 

…and thus the day is saved.

Story

Looking to pull timeout settings for Red Hat virtualization Server 4.3.x from the engine DB for a colleague, and finding that rh-postgresql10 does not appear to have been setup with the correct paths.

References

https://bugzilla.redhat.com/show_bug.cgi?id=1631185 WONTFIX (resolved in rh-postgresql12 - comment 8 suggests a .conf solution and the workaround above).

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: