Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

make fails because pgxs.mk is missing when building a PostgreSQL extension

ErrorMakefile:10: /usr/pgsql-14/lib/pgxs/src/makefiles/pgxs.mk: No such file or directory

Short answer

The extension's Makefile asks pg_config where the PGXS makefile is, then includes it. The error means that path does not exist: the PostgreSQL development files are not installed for that version, or pg_config belongs to a different installation than the one you meant. Print pg_config --pgxs and check the file.

  • Applies to PostgreSQL 14, PostgreSQL 16, RHEL 9, Rocky Linux 9
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print which pg_config make uses, what it reports, and whether the makefile it names exists.

    which pg_config
    pg_config --version
    ls -l "$(pg_config --pgxs)"
  2. 2Match what you see, then jump to its fix

    1. 1pg_config prints a path under the version's lib/pgxs folder and ls says No such fileThe PostgreSQL development package is not installedFix
    2. 2which pg_config shows a different version or folder than the server you will load the extension intomake picks up a pg_config from another installationFix

What does the error look like?

  • Makefile:10: /usr/pgsql-14/lib/pgxs/src/makefiles/pgxs.mk: No such file or directory
  • make: *** No rule to make target '/usr/pgsql-14/lib/pgxs/src/makefiles/pgxs.mk'. Stop.

Cause 1 of 2

The PostgreSQL development package is not installed

1Check

pg_config reports where the extension makefiles are meant to be. If the build files were never installed, the path points at nothing. The PGDG packages ship the headers and libraries for C development in a separate postgresql-devel package.

rpm -qa | grep -i postgresql

2Fix

Install the devel package for the same major version as the server, from the same repository, and run make again.

sudo dnf install postgresql14-devel
make

3Verify

The makefile now exists, and the build runs.

ls -l "$(pg_config --pgxs)"
make

Confirmed by postgresql.org

Did this fix it?

Cause 2 of 2

make picks up a pg_config from another installation

1Check

By default PGXS builds for the first pg_config found in PATH. The extension will be built, and installed, for that installation.

pg_config --version --bindir

2Fix

Name the pg_config of the target installation on the make command line, or put its bin folder first in PATH.

make PG_CONFIG=/usr/pgsql-14/bin/pg_config
sudo make install PG_CONFIG=/usr/pgsql-14/bin/pg_config

3Verify

pg_config --pgxs for that installation points at an existing file.

ls -l "$(/usr/pgsql-14/bin/pg_config --pgxs)"

Confirmed by postgresql.org

Did this fix it?

How do I stop it coming back?

  • Install the devel package at the same time as the server package, always for the same major version.
  • Pass PG_CONFIG explicitly in build scripts when more than one PostgreSQL version is installed.
  • Print pg_config --version at the start of a build script so the log shows what it built against.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.