sh: 1: less: not found when using PSQL commands

Viewed 14

I installed Postgres and I'm using the psql tool. Some queries work fine, like SELECT current_date; and SELECT 2 + 2;. But others like \h throw an error sh: 1: less: not found, queries like SELECT * FROM foo also throw this error. I didn't find anything reporting this error neither in the docs or other forums. What could it be?

I'm using Ubuntu 20.04 and postgres 14.5

1 Answers

I discovered it. I messed my PATH variable when I added a shortcut to the postgres bin files.

My PATH variable was written in .bashrc like this:

# Set environment PATH for postgres 14
PATH="/usr/lib/postgresql/14/bin/"

What fixed was rewrite to:

# Set environment PATH for postgres 14
export PATH="/usr/lib/postgresql/14/bin/:$PATH"

Hope it helps someone some day.

Related