15

I just installed ubunutu 18.04 and I successfully install R version 3.5.1. I am having problems installing R packages such as plotly. It seems that the packages curl and httr are not available. The full error message:

> install.packages("plotly")
Installing package into ‘/home/lualeperez/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependencies ‘curl’, ‘openssl’, ‘httr’

trying URL 'https://cloud.r-project.org/src/contrib/curl_3.2.tar.gz'
Content type 'application/x-gzip' length 367047 bytes (358 KB)
==================================================
downloaded 358 KB

trying URL 'https://cloud.r-project.org/src/contrib/openssl_1.0.2.tar.gz'
Content type 'application/x-gzip' length 1194883 bytes (1.1 MB)
==================================================
downloaded 1.1 MB

trying URL 'https://cloud.r-project.org/src/contrib/httr_1.3.1.tar.gz'
Content type 'application/x-gzip' length 147593 bytes (144 KB)
==================================================
downloaded 144 KB

trying URL 'https://cloud.r-project.org/src/contrib/plotly_4.8.0.tar.gz'
Content type 'application/x-gzip' length 1860673 bytes (1.8 MB)
==================================================
downloaded 1.8 MB

* installing *source* package ‘curl’ ...
** package ‘curl’ successfully unpacked and MD5 sums checked
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/lualeperez/R/x86_64-pc-linux-gnu-library/3.5/curl’
* installing *source* package ‘openssl’ ...
** package ‘openssl’ successfully unpacked and MD5 sums checked
Using PKG_CFLAGS=
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because openssl was not found. Try installing:
 * deb: libssl-dev (Debian, Ubuntu, etc)
 * rpm: openssl-devel (Fedora, CentOS, RHEL)
 * csw: libssl_dev (Solaris)
 * brew: openssl@1.1 (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.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 ‘openssl’
* removing ‘/home/lualeperez/R/x86_64-pc-linux-gnu-library/3.5/openssl’
ERROR: dependencies ‘curl’, ‘openssl’ are not available for package ‘httr’
* removing ‘/home/lualeperez/R/x86_64-pc-linux-gnu-library/3.5/httr’
ERROR: dependency ‘httr’ is not available for package ‘plotly’
* removing ‘/home/lualeperez/R/x86_64-pc-linux-gnu-library/3.5/plotly’

The downloaded source packages are in
    ‘/tmp/RtmpNTZBPJ/downloaded_packages’
Warning messages:
1: In install.packages("plotly") :
  installation of package ‘curl’ had non-zero exit status
2: In install.packages("plotly") :
  installation of package ‘openssl’ had non-zero exit status
3: In install.packages("plotly") :
  installation of package ‘httr’ had non-zero exit status
4: In install.packages("plotly") :
  installation of package ‘plotly’ had non-zero exit status

I tried to solve the problem by installing libcurl4 by doing

sudo apt-get install libcurl4

but the systems then removes all the r-base dependencies.

I haven't tried to solve the problem with the httr package.

Does any one have any hint on how to solve this problem?

MrFlick
  • 195,160
  • 17
  • 277
  • 295
Alejandro Perez
  • 151
  • 1
  • 1
  • 4
  • You need the _development_ library `libcurl4-openssl-dev` (as the message shows) not the _runtime_ library `libcurl4` you are installing. But as my answer below suggests, you could also install a binary package and be done. – Dirk Eddelbuettel Aug 29 '18 at 17:51
  • I tried to install libcurl4-openssl-dev, but the system tells me to install libcurl4 first and when I try to install this last one the system tell me that it is going to uninstall r-base. I don' t really understand when you say that I should install a binary package. – Alejandro Perez Aug 30 '18 at 07:08
  • @DirkEddelbuettel I ran into the same problem when trying to install the "httr" package in R in a container created using the r-base Docker image. My `install.packages("httr", dependencies = TRUE)` spat three ANTICONF ERRORs, complaining that "libcurl4-openssl-dev", "libssl-dev" and "libxml2-dev" were missing. I then installed these three packages on the terminal using `sudo apt install`, and `apt list` confirmed that they've been installed, but installation of "httr" still failed with the three ANTICONF ERRORs. What was wrong? – elarry Dec 15 '22 at 19:47
  • If you have issues compiling I *strongly* suggest you jsut move on and do `sudo apt install r-cran-httr`. Also see https://eddelbuettel.github.io/r2u/ for *all* of CRAN on Ubuntu. – Dirk Eddelbuettel Dec 15 '22 at 19:50

3 Answers3

16

Just ran into the same issue, this is the solution I found:

Since just installing libcurl4-openssl-dev removes all the r-base packages what I did was

sudo apt-get install libcurl4-openssl-dev r-base

and afterwards

R -q -e "install.packages(c('curl'))"

and it worked.

Only caveat is that it upgrades your R version, but if you are already using the latest one then its not an issue.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Carlos Rodriguez
  • 611
  • 5
  • 11
10

You are attempting to compile from source. That sometimes has so-called build dependencies. You are missing them, and you are overlooking the (somewhat clear) error messages to that extend because you are getting swamped by multiple installations.

So first tip, so it one package at a time.

Second tip: realize that many (if not all) of these are available within Ubuntu. So just do

sudo apt install r-cran-curl

to install e.g. curl. Ditto for the others.

Third tip: There are over 3000 CRAN packages for Ubuntu at Michael's PPA. Read the top of this README and then go this PPA (provided you want 3.5 which you do).

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • 1
    Many thanks for your answer. I am sorry if the problem is trivial, but am a bit new in this. I tried to install r-cran-curl but the systems tells me to install first libcurl4. If I try to install this last one the system tells me that it is going to uninstall r-base. – Alejandro Perez Aug 30 '18 at 07:06
  • I followed the instructions in https://cloud.r-project.org/bin/linux/ubuntu/README.html and https://launchpad.net/~marutter/+archive/ubuntu/c2d4u3.5, then did sudo apt-get update. I then tried to install r-cran-curl but got the same messages. – Alejandro Perez Aug 30 '18 at 07:11
0

Fedora 36:

dnf install cmake
dnf install openssl-devel
dnf install libcurl-devel.x86_64
Rui Barradas
  • 70,273
  • 8
  • 34
  • 66