Packages installation process failed on Linux (probably due to missing path in the pkg-config search path)

Hi,
Recently I was trying to execute my R scripts on Linux platform (Ubuntu 18.4) and I had difficulties with each package installation process through "package.installation() function.

install.packages("rvest", dependencies = TRUE)

Each time I get an error message like this:

  • installing source package ‘curl’ ...
    ** package ‘curl’ successfully unpacked and MD5 sums checked
    ** using staged installation"
    Package libcurl was not found in the pkg-config search path.
    Perhaps you should add the directory containing libcurl.pc' to the PKG_CONFIG_PATH environment variable No package 'libcurl' found Package libcurl was not found in the pkg-config search path. Perhaps you should add the directory containing libcurl.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libcurl' found
    Using PKG_CFLAGS=
    Using PKG_LIBS=-lcurl
    ------------------------- ANTICONF ERROR ---------------------------
    Configuration failed because libcurl was not found. Try installing:
  • deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
  • rpm: libcurl-devel (Fedora, CentOS, RHEL)
  • csw: libcurl_dev (Solaris)
    If libcurl is already installed, check that 'pkg-config' is in your
    PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
    is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
    R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'

ERROR: configuration failed for package ‘curl’

  • removing ‘/home/marcelina/R/x86_64-pc-linux-gnu-library/3.6/curl’
    Warning in install.packages :
    installation of package ‘curl’ had non-zero exit status"

So I created a new variable PKG_CONFIG_PATH assigning it a path where packages are installed by default.
The default path is:

 > .libPaths()
[1] "/home/marcelina/R/x86_64-pc-linux-gnu-library/3.6". 

in bash:
export PKG_CONFIG_PATH=/home/marcelina/R/x86_64-pc-linux-gnu-library/3.6"

That didn't help, so I added this path value to an environmental variable PATH:
in bash:
export PATH=$PATH:/home/marcelina/R/x86_64-pc-linux-gnu-library/3.6

that also didn't work.

I saw some package installation problems on the forum but there seem to be not solved.

Did anybody overcome similar problem?

The error message is asking you to install a system library not an R package so adding .libPaths() to your PATH is not going to help, just install the requested system library following the instructions on the error message.

sudo apt install libcurl4-openssl-dev
3 Likes

Debian 10.
R version 3.6.2 (2019-12-12)

install.packages("tidyverse")
...
Using PKG_CFLAGS=
Using PKG_LIBS=-lcurl
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------

So exactly same problem.

As a SUDO user I run on terminal:

sudo apt-get install libcurl4-openssl-dev

And I get the next error:
The following packages have unmet dependencies:
libcurl4-openssl-dev : Depends: libcurl4 (= 7.64.0-4) but it is not going to be installed

Then I try to install dependencies:

sudo apt-get install libcurl4

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libblas-dev
libbz2-dev libgfortran3 libjpeg-dev libjpeg62-turbo-dev liblapack-dev
liblzma-dev libminiupnpc17 libnatpmp1 libncurses-dev libncurses5-dev
libpcre16-3 libpcre2-32-0 libpcre2-dev libpcre2-posix0 libpcre3-dev
libpcre32-3 libpcrecpp0v5 libpng-dev libpng-tools libreadline-dev
r-cran-boot r-cran-cluster r-cran-foreign r-doc-html transmission-common
zlib1g-dev
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
libcurl3 r-base-core r-base-dev r-cran-class r-cran-codetools
r-cran-kernsmooth r-cran-lattice r-cran-mass r-cran-matrix r-cran-mgcv
r-cran-nlme r-cran-nnet r-cran-rpart r-cran-spatial r-cran-survival
r-recommended
The following NEW packages will be installed:
libcurl4
0 upgraded, 1 newly installed, 16 to remove and 0 not upgraded.

Thus, to install libcurl4-openssl-dev Debian uninstalls R itself, anf if I install R again, Debian uninstall
libcurl4-openssl-dev, and install libcurl3 instead.

Far to be solved ...this question is.

UPDATE

Following this thread https://stackoverflow.com/questions/42115972/configuration-failed-because-libcurl-was-not-found

I downloaded curl-7.55.0.tar.gz, then install from terminal, and everything is OK.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.