BUG #19624: postgresql14-devel (and in general postgresqlXX-devel) do not set PKG_CONFIG_PATH
The following bug has been logged on the website:
Bug reference: 19624
Logged by: Michael Mayer
Email address: michael.mayer@posit.co
PostgreSQL version: 14.24
Operating system: Red Hat Enterprise Linux (any)
Description:
I love your common repository where you offer more up-to-date versions of
`gdal`, `proj` and `geos` for RHEL based linux distros. This enables many
users to leverage those libraries when installing R packages that depend on
versions of the mentioned packages that are newer compared to what Red Hat
ships.
When using the repository, any installation of `libpq-devel` will
automatically install `postgresql14-devel`. This is fine in general and from
a runtime linking perspective `postgresql14-libs` works as expected. When
building an R package such as `RPostgresql` from source however, it fails to
find both the include files and libraries to link to. This is caused by a
non-existing `PKG_CONFIG_PATH` setting.
It would be great if we could add a `%post` script to the
`postgresql14-devel` RPM that would append the location of the pkgconfig
files (e.g. `/usr/pgsql-14/lib/pkgconfig/`) to `PKG_CONFIG_PATH`. This will
ensure that the include files and libs are found at configure and compile
time as well.
Example when installing `RPostgres` R package in RockyLinux 10 from sources
[root@a11d116ef183 /]# /opt/R/4.6.0/bin/R -q -e 'pak::pak(c("RPostgres"))'
pak::pak(c("RPostgres"))
✔ Updated metadata database: 2.87 MB in 8 files.
✔ Updating metadata database ... done
→ Package library at /opt/R/4.6.0/lib/R/library.
→ Will install 1 package.
→ Will download 1 CRAN package (1.47 MB).
+ RPostgres 1.4.10 [bld][cmp][dl] (1.47 MB) + ✖ libpq-devel
→ Will install 1 system package:
+ libpq-devel - RPostgres
ℹ Getting 1 pkg (1.47 MB)
✔ Got RPostgres 1.4.10 (source) (1.46 MB)
ℹ Installing system requirements
ℹ Executing `sh -c dnf install -y libpq-devel`
ℹ Building RPostgres 1.4.10
^[[A✖ Failed to build RPostgres 1.4.10 (5.8s)
Error:
! error in pak subprocess
Caused by error in `stop_task_build(state, worker)`:
! Failed to build source package RPostgres.
Full installation output:
* installing *source* package ‘RPostgres’ ...
** this is package ‘RPostgres’ version ‘1.4.10’
** package ‘RPostgres’ successfully unpacked and MD5 sums checked
staged installation is only possible with locking
** using non-staged installation
Using PKG_CFLAGS=
Using PKG_LIBS=-lpq
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libpq was not found. Try installing:
* deb: libpq-dev libssl-dev (Debian, Ubuntu, etc)
* rpm: postgresql-devel (Fedora, EPEL)
* rpm: postgreql8-devel, postgresql92-devel, postgresql93-devel, or
postgresql94-devel (Amazon Linux)
* csw: postgresql_dev (Solaris)
* brew: libpq (OSX)
If libpq is already installed, check that either:
(i) 'pkg-config' is in your PATH AND PKG_CONFIG_PATH contains
a libpq.pc file; or
(ii) 'pg_config' is in your PATH.
If neither can detect , you can set INCLUDE_DIR
and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------[ ERROR MESSAGE ]----------------------------
<stdin>:1:10: fatal error: libpq-fe.h: No such file or directory
compilation terminated.
-----------------------------------------------------------------------
ERROR: configuration failed for package ‘RPostgres’
* removing ‘/tmp/Rtmp86r4DO/pkg-lib72f74d2a627/RPostgres’
---
Backtrace:
1. pak::pak(c("RPostgres"))
2. pak::pkg_install(pkg, ...)
3. pak:::remote(function(...) get("pkg_install_do_plan",
asNamespace("pak"))(...), …
4. err$throw(res$error)
---
Subprocess backtrace:
1. base::withCallingHandlers(cli_message = function(msg) { …
2. get("pkg_install_do_plan", asNamespace("pak"))(...)
3. proposal$install()
4. pkgdepends::install_package_plan(plan, lib = private$library,
num_workers = nw, …
5. base::withCallingHandlers({ …
6. pkgdepends:::handle_events(state, events)
7. pkgdepends:::handle_event(state, i)
8. pkgdepends:::stop_task(state, worker)
9. pkgdepends:::stop_task_build(state, worker)
10. base::throw(pkg_error("Failed to build source package {.pkg {pkg}}.", …
11. | base::signalCondition(cond)
12. global (function (e) …
Execution halted
[root@a11d116ef183 /]# export
PKG_CONFIG_PATH=/usr/pgsql-14/lib/pkgconfig:$PKG_CONFIG_PATH
[root@a11d116ef183 /]# /opt/R/4.6.0/bin/R -q -e 'pak::pak(c("RPostgres"))'
pak::pak(c("RPostgres"))
✔ Loading metadata database ... done
→ Package library at /opt/R/4.6.0/lib/R/library.
→ Will install 1 package.
→ Will download 1 CRAN package (1.47 MB).
+ RPostgres 1.4.10 [bld][cmp][dl] (1.47 MB) + ✖ libpq-devel
→ Will install 1 system package:
+ libpq-devel - RPostgres
ℹ Getting 1 pkg (1.47 MB)
✔ Cached copy of RPostgres 1.4.10 (source) is the latest build
ℹ Installing system requirements
ℹ Executing `sh -c dnf install -y libpq-devel`
ℹ Building RPostgres 1.4.10
✔ Built RPostgres 1.4.10 (38.7s)
✔ Installed RPostgres 1.4.10 (1.1s)
✔ 1 pkg + 16 deps: kept 16, added 1 [44.7s]
[root@a11d116ef183 /]#