1

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?

tokamak32
  • 27
  • 7

14 Answers14

1

On linux there are some pre-installed postgresql packages, because of any issue you don't have that. You can run this command to install.

sudo apt install postgresql-server-dev-11

After installing this, if you still have same error you can run

sudo apt update
0

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

echo $PATH

output should include (may changes based on installation)

/usr/local/pgsql/bin

You can add your bin path permanently to $PATH variable if it is not added through editing your .bashrc file

export PATH="/usr/local/pgsql/bin:$PATH"
0

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.

0

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:

sudo apt install postgresql-server-dev-14

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.

0

You may need to export the PATH variable first.

  1. Type the following command in the terminal to open the .bashrc file:
nano ~/.bashrc
  1. Add the path to your bin in the file:
export PATH="/usr/local/pgsql/bin:$PATH"
  1. To apply these changes, run:
source ~/.bashrc

Confirm this by echo $PATH in the terminal.

Safi50
  • 379
  • 1
  • 7
0

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 using source ~/.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.

abhishek2046
  • 312
  • 1
  • 11
0
export PATH="$PATH:/usr/pg/dist/postgresql-12.14/bin/"
export LD_LIBRARY_PATH="/usr/pg/dist/postgresql-12.14/lib/"

these commands will help you

0

I had the same problem, downloading the build tool for multiple postgres version using this command helped sudo apt install postgresql-server-dev-all or this command sudo apt install postgresql-common before downloading the postgreSQL file helped.

0

I had the same issue. You have to install the PostgreSQL development package, which is why the 'pg_config' command is not found. To resolve this issue please follow these steps:

  1. Update the package using sudo apt update
  2. Install the PostgreSQL development package using: sudo apt install postgresql-server-dev-all

to verify the installation try running 'pg_config' command again in the terminal.

0

You get the command not found because your system doesn't know where to find the command, you can resolve this issue by locating the install path of your postgres version 12, and also find the pg_config executable within this directory, and then add the path of the pg_config executable to the PATH environment variable. Now the command should work

Peter
  • 43
  • 4
0

There could be two possible solutions as to why you can't run the pgconfig command the first may be absence of PostgreSQL development packages for this run the commands

sudo apt install postgresql-server-dev-14
sudo apt update

The other could be that your enviornment variable hae not be set properly for this edit your .bashrc file

export PATH="/usr/local/pgsql/bin:$PATH"

then run

source ~/.bashrc

I hope this helps to solve your problem.

0

Run These Commands In Sequence hopefully it will resolve the issue

  1. sudo apt-get update

  2. sudo apt-get install postgresql-server-dev-12

  3. sudo find / -name pg_config

  4. export PATH="/path/to/postgres/bin:$PATH" Replace /path/to/postgres/bin with the actual directory path where you found pg_config.

  5. make

  6. sudo make install

  7. psql -U your_username -d your_database

  8. CREATE EXTENSION age;

0

Usually, In Ubuntu, You can find preinstall packages for PostgreSQL. Your Ubuntu system is missing these packages and that's why you are facing this issue. This is common with using Virtual Machines.

Run the following command to install these packages:

sudo apt install postgres-sql-server-dev-14

Then run:

sudo apt update

Hopefully, this will make the issue go away. In case it persists, there might be an issue with path variable.

Saif Ali
  • 53
  • 3
0

It seems that the PATH variable has not been set up correctly for your postgreSQL installation. Type sudo nano ~/.profile and add your actual path to the postgreSQL installation export PATH=$PATH:/path/to/postgres/bin then source ~/.profile to apply the changes. Typing psql --version should give you your postgres version and you should be able to call it's functions then.

Hassoo
  • 85
  • 11