1

Error : Makefile:120: /usr/lib/postgresql/12/lib/pgxs/src/makefiles/pgxs.mk: No such file or directory make: *** No rule to make target '/usr/lib/postgresql/12/lib/pgxs/src/makefiles/pgxs.mk'.

I'm using pgenv for postgreSQL version management, before I was using PostgreSQL 12 and 13 via pgenv only and sudo make install was working.

I wanted to test Apache-AGE on PG14, so I installed PG14 using pgenv build 14.0. PostgreSQL server is up and running I've test some queries.

But I'm getting error while installing from source. Error on line 120 in makefile i.e

PG_CONFIG ?= pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

Make file is executing pg_config --pgxs command to get pgxs path, and it's getting old pgxs path when we install postgreSQL by conventional method i.e from apt repository.

HOWEVER I'm executing the same command pg_config --pgxs I'm getting the correct path in terminal

~ pg_config --pgxs

/home/sarthak/pgenv/pgsql-14.0/lib/pgxs/src/makefiles/pgxs.mk

I've tried this command on default shell zsh and bash.

So if it's giving proper path of pgxs, why make file is getting different path on running the same command?

Now I'm getting this error on all postgreSQL version, before which was working on that too.

EDIT: adding output of pg_config when run from terminal

pg_config                                                                        ✔  10.4G   
BINDIR = /home/sarthak/pgenv/pgsql-14.0/bin
DOCDIR = /home/sarthak/pgenv/pgsql-14.0/share/doc
HTMLDIR = /home/sarthak/pgenv/pgsql-14.0/share/doc
INCLUDEDIR = /home/sarthak/pgenv/pgsql-14.0/include
PKGINCLUDEDIR = /home/sarthak/pgenv/pgsql-14.0/include
INCLUDEDIR-SERVER = /home/sarthak/pgenv/pgsql-14.0/include/server
LIBDIR = /home/sarthak/pgenv/pgsql-14.0/lib
PKGLIBDIR = /home/sarthak/pgenv/pgsql-14.0/lib
LOCALEDIR = /home/sarthak/pgenv/pgsql-14.0/share/locale
MANDIR = /home/sarthak/pgenv/pgsql-14.0/share/man
SHAREDIR = /home/sarthak/pgenv/pgsql-14.0/share
SYSCONFDIR = /home/sarthak/pgenv/pgsql-14.0/etc
PGXS = /home/sarthak/pgenv/pgsql-14.0/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE =  '--prefix=/home/sarthak/pgenv/pgsql-14.0'
CC = gcc
CPPFLAGS = -D_GNU_SOURCE
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing-fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2
CFLAGS_SL = -fPIC
LDFLAGS = -Wl,--as-needed -Wl,-rpath,'/home/sarthak/pgenv/pgsql-14.0/lib',--enable-new-dtags
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lz -lreadline -lpthread -lrt -ldl -lm
VERSION = PostgreSQL 14.0
Sarthak
  • 380
  • 7

6 Answers6

2

PG_CONFIG is not the path to makefiles. It is path to the bin folder where all the binaries are.

Try changing the value of PG_CONFIG using:

export PG_CONFIG=/path/to/postgres/14/bin
Mohayu Din
  • 433
  • 9
  • `pgenv` handles setting correct path to `pg_config`, also I've mentioned that pg_config is pointing to correct path to postgres bin , I can confirm this by running running from terminal. – Sarthak Jul 17 '23 at 08:55
1

This problem should be common for anyone using pgenv. What happens is, when we uninstall the postgresql which was installed via sudo apt install postgresql-server-dev-all, the pg_config binary located in /usr/bin does not get deleted.

pgenv installs new postgreSQL builds in it's root directory and location of pg_config is /home/sarthak/pgenv/pgsql/bin/pg_config and it is added into User PATH and not sudo PATH

so if we run command like make install it'll work i.e without sudo. But when we run sudo make install the make file execute pg_config --pgxs in sudo environment, and it looks for pg_config in /usr/bin directory because it is in the sudo path.

Solution : Make a soft-link of pg_config located in /pgenv/pgsql/bin/pg_config to /usr/bin using command : run this while being in /usr/bin directory

sudo ln -s /home/sarthak/pgenv/pgsql/bin/pg_config pg_config

then it should work with or without sudo

Sarthak
  • 380
  • 7
0

You should run

 pgenv config write 14.0 && pgenv config edit 14.0

adjust 'configure' and 'make' options and flags and run build again

You can read more about configuring pgevn build here.

Wendel
  • 763
  • 1
  • 12
0

I advise you should install postgreSQL from source code. By doing that you can eaisly set proper flags as such First download latest postgresql 14 version

wget https://ftp.postgresql.org/pub/source/v14.9/postgresql-14.9.tar.gz && tar -xvf postgresql-14.9.tar.gz && rm -f postgresql-14.9.tar.gz

Then go to directory

 cd postgresql-14.9

Then to set flags

./configure --enable-debug --enable-cassert --prefix=$(pwd) CFLAGS="-ggdb -Og -fno-omit-frame-pointer"

Then run the command

make install

After that you should be able to install AGE easily with the proper path.

0

You should try to install Postgres and AGE from Source code. And should check for the compatibility of both. As you are installing v12.So, you can check others comment to install posgres-v12, to install age you can run following commands.

git clone https://github.com/apache/age.git

cd age then checkout to PG12 branch by running command

git checkout PG12

install that branch

make PG_CONFIG=/home/username/age16/pg//bin/pg_config install

Update this make command PG_CONFIG path according to your directory structure.

Zeeshan
  • 71
  • 2
0

Try to install postgres 14 from source code, by running the command below,

https://ftp.postgresql.org/pub/source/v11.18/postgresql- 
14.9.tar.gz && tar -xvf postgresql-11.18.tar.gz && rm -f 
postgresql-11.18.tar.gz

Enter into this directory.

cd postgresql-11.18 

Enable debug flags.

./configure --enable-debug --enable-cassert --prefix=$(pwd) 
CFLAGS="-ggdb -Og -fno-omit-frame-pointer" 
make install 

With the command above, you can easily install Postgres from source code for AGE, then proceed with your AGE installation.