psql: symbol lookup error: psql: undefined symbol: PQsetErrorContextVisibility
Asked Answered
E

5

5

I switched my postgres version from 9.2.24 to 9.6 because I need jsonb compatibility along with other recent features. I am running a vm on centos 7.

I decided to wipe all existing instances of postgres (which are almost empty since it is staging) and then installed 9.6. However, once I enter the postgres shell I received the following error when I type psql:

psql: symbol lookup error: psql: undefined symbol: PQsetErrorContextVisibility

I assume I need to change the path that psql is looking for so that it connects properly but I am not sure where to point it.

Note: ls reveals 2 directories and 1 file in postgres bash 9.6 data and initdb.log.

Extravert answered 12/9, 2018 at 20:49 Comment(4)
try export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/Shrewmouse
@VaoTsun, this was the solution for me. The libpq.so shared library was located in /usr/lib64. Adding this path to LD_LIBRARY_PATH and running ldconfig did the trick.Ubiquitous
Isn't the location /usr/lib/x86_64-linux-gnu/libpq.so.5? (reference packages.debian.org/stretch/amd64/libpq5/filelist)Colly
Hi @Ubiquitous and all could you please help me here #76272514Haemostasis
S
2

psql: symbol lookup error: psql: undefined symbol: PQsetErrorContextVisibility

That means your copy of psql is looking for a dynamic symbol in libpq.so which the version in your path does not have.

Do you have a custom compiled version of psql? And, if so, you'll have to build it against the newer libpq that 9.6 provides.

Sporocyst answered 12/9, 2018 at 21:41 Comment(0)
F
4

Try

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<your postgres lib directory>

For example

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/ 

(turning @vaotsun's comment into an answer)

Faeroese answered 18/9, 2020 at 18:39 Comment(0)
S
2

psql: symbol lookup error: psql: undefined symbol: PQsetErrorContextVisibility

That means your copy of psql is looking for a dynamic symbol in libpq.so which the version in your path does not have.

Do you have a custom compiled version of psql? And, if so, you'll have to build it against the newer libpq that 9.6 provides.

Sporocyst answered 12/9, 2018 at 21:41 Comment(0)
P
1

Just faced this because of red hat SCL. I got away with the following.

ln -s /opt/rh/rh-postgresql96/root/usr/lib64/libpq.so.rh-postgresql96-5.9 /opt/rh/rh-postgresql96/root/usr/lib64/libpq.so.5

ln -s /opt/rh/rh-postgresql96/root/usr/lib64/libpq.so.5 /usr/lib/libpq.so.5

In wouldn't advise my worst enemy about using software coming from SCL repository in place of an external repo (see postgresql 96 on centos 7).

Padilla answered 1/11, 2019 at 10:36 Comment(0)
A
1

Agree with @interestedparty333. You can find the exact missing lib and add the folder to LD_LIBRARY_PATH.

Example:

find ~+ -name libpq.so.5

It can give a result like below (~+ gives absolute path as a result of find):

/home/myuser/postgresql-12.9/src/interfaces/libpq/libpq.so.5

So you can add a folder (absolute path) to LD_LIBRARY_PATH like:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/myuser/postgresql-12.9/src/interfaces/libpq/

Now psql should work OK. In case you would need additional lib, find&add like above for every missing one.

Aristarchus answered 24/11, 2021 at 11:13 Comment(0)
K
0

It's very simple:

Find where your binary is first with whereis psql

For me it returned a bunch of stuff and also /usr/bin/psql

Then set LD_LIBRARY_PATH equal to that or containing that path. But removing the 2 last elements: bin/psql.

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr

or

LD_LIBRARY_PATH=/usr

Source: https://www.postgresql.org/message-id/20210604223837.GA7689%40momjian.us

Kirsti answered 19/8 at 11:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.