I’m trying to run the Apache AGE extension on Ubuntu 22. I have postgres 12.14 installed, and I’ve cloned the AGE repository as instructed in the documentation. However, when I try running the pg_config command, bash says that this command does not exist.
What am I doing wrong?
6
Answers
You should have added postgresql’s bin directory to the $PATH (environment variables) to be accessed directly using pg_config
otherwise you will need to call it from its original path i.e.
/usr/local/pgsql/bin/pg_config
During the installation of AGE you will add that to the PG_CONFIG parameter
To make sure of your paths to check whether Postgresql’s bin is included or not
output should include (may changes based on installation)
You can add your bin path permanently to $PATH variable if it is not added through editing your .bashrc file
In order to run pg_config you either need to export it via:
export PATH="/usr/local/pgsql/bin:$PATH"
Although I suggest going into the .bashrc file and adding the above command directly there because if you don’t do that you would have to export the path everytime you close the session.
I also faced this problem when I switched from Ubuntu 18.04 to 22.04. May be Ubuntu 22.04 system does not come pre-installed with the PostgreSQL development packages, which normally contain the pg_config command. So I tried to Install the PostgreSQL development packages:
This script will install the development files necessary to create PostgreSQL extensions for PostgreSQL version 12. The
pg_config
command should work after installing the postgresql-server-dev-14 package, allowing you to choose the best build configurations for your AGE extension.You may need to export the PATH variable first.
Confirm this by
echo $PATH
in the terminal.The path to pg_config is added to the PATH variable on installation, but if it was not done automatically for some reason, you can add it manually by adding
export PATH="$PATH:/path/to/postgresql/installation/bin"
at the end of
.bashrc
or.bash_profile
files and then usingsource ~/.bashrc
If you do not know the original path of the pg_config file, you can use the command
find . -name pg_config
. The pg_config file which we need is directly under the bin directory.After exporting you can check it by using
which pg_config
. This should return the path to the executable file.these commands will help you