Description
Hello, I'm trying to install RPostgres in the a Docker container. However, the compilation fails because the libpq-fe.h file can't be found even though it exists:
# locate libpq-fe.h
/usr/include/postgresql/libpq-fe.h
This is the error message:
> install.packages("RPostgres")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/RPostgres_1.4.1.tar.gz'
Content type 'application/x-gzip' length 1551420 bytes (1.5 MB)
==================================================
downloaded 1.5 MB
* installing *source* package ‘RPostgres’ ...
** package ‘RPostgres’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs (libpq 14.0)!
Using PKG_CFLAGS=
Using PKG_LIBS=-lpq
Using PKG_PLOGR=
** libs
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -Ivendor -DRCPP_DEFAULT_INCLUDE_CALL=false -DRCPP_USING_UTF8_ERROR_STRING -DBOOST_NO_AUTO_PTR -I'/usr/local/lib/R/site-library/plogr/include' -I'/usr/local/lib/R/site-library/Rcpp/include' -fvisibility=hidden -fpic -g -O2 -ffile-prefix-map=/build/r-base-4.1.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c DbColumn.cpp -o DbColumn.o
In file included from DbColumn.cpp:1:
pch.h:2:10: fatal error: libpq-fe.h: No such file or directory
2 | #include <libpq-fe.h>
| ^~~~~~~~~~~~
compilation terminated.
make: *** [/usr/lib/R/etc/Makeconf:177: DbColumn.o] Error 1
ERROR: compilation failed for package ‘RPostgres’
* removing ‘/usr/local/lib/R/site-library/RPostgres’
The downloaded source packages are in
‘/tmp/RtmpvKl0f8/downloaded_packages’
Warning message:
In install.packages("RPostgres") :
installation of package ‘RPostgres’ had non-zero exit status
This is the Docker image I'm building:
FROM rocker/r-base:4.1.1
RUN apt update
RUN apt install -y libcurl4-openssl-dev libmagick++-dev libpq-dev unixodbc-dev
ENTRYPOINT ["tail", "-f", "/dev/null"]
I set the following environment variables inside the container:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/include/postgresql
export C_INCLUDE_PATH=$(pg_config --includedir):${C_INCLUDE_PATH}
export LD_LIBRARY_PATH=$(pg_config --libdir):${LD_LIBRARY_PATH}
I can install RPostgreSQL without any problems so I don't think it's an issue with libpq-dev.
This is the output from pg_config:
pg_config
BINDIR = /usr/lib/postgresql/14/bin
DOCDIR = /usr/share/doc/postgresql-doc-14
HTMLDIR = /usr/share/doc/postgresql-doc-14
INCLUDEDIR = /usr/include/postgresql
PKGINCLUDEDIR = /usr/include/postgresql
INCLUDEDIR-SERVER = /usr/include/postgresql/14/server
LIBDIR = /usr/lib/x86_64-linux-gnu
PKGLIBDIR = /usr/lib/postgresql/14/lib
LOCALEDIR = /usr/share/locale
MANDIR = /usr/share/postgresql/14/man
SHAREDIR = /usr/share/postgresql/14
SYSCONFDIR = /etc/postgresql-common
PGXS = /usr/lib/postgresql/14/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-option-checking' '--disable-silent-rules' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--runstatedir=/run' '--disable-maintainer-mode' '--disable-dependency-tracking' '--with-icu' '--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' 'PYTHON=/usr/bin/python3' '--mandir=/usr/share/postgresql/14/man' '--docdir=/usr/share/doc/postgresql-doc-14' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/14' '--bindir=/usr/lib/postgresql/14/bin' '--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--with-extra-version= (Debian 14.0-1)' '--enable-nls' '--enable-thread-safety' '--enable-tap-tests' '--enable-debug' '--enable-dtrace' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' '--with-lz4' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' '--with-llvm' 'LLVM_CONFIG=/usr/bin/llvm-config-11' 'CLANG=/usr/bin/clang-11' '--with-systemd' '--with-selinux' 'AWK=mawk' 'MKDIR_P=/bin/mkdir -p' 'PROVE=/usr/bin/prove' 'TAR=/bin/tar' 'XSLTPROC=xsltproc --nonet' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer' 'LDFLAGS=-Wl,-z,relro -Wl,-z,now' '--with-gssapi' '--with-ldap' 'build_alias=x86_64-linux-gnu' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'
CC = gcc
CPPFLAGS = -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2
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 -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer
CFLAGS_SL = -fPIC
LDFLAGS = -Wl,-z,relro -Wl,-z,now -L/usr/lib/llvm-11/lib -Wl,--as-needed
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lselinux -llz4 -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lpthread -lrt -ldl -lm
VERSION = PostgreSQL 14.0 (Debian 14.0-1)