Configuration failed because libcurl was not found

RUbuntuCurl

R Problem Overview


I am trying to pull some json data from a remote server using fromJSON:

> server <- 'http://111.111.000.00:3000'
> streams <- fromJSON(paste(server, '/output/streams', sep=""), flatten=TRUE)

Result:

Error: Required package curl not found. 
Please run: install.packages('curl')

So I tried to install it:

> install.packages("curl")
Installing package into ‘/home/lauxxx/R/x86_64-pc-linux-gnu-library/3.3’
(aslibis unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/curl_2.3.tar.gz'
Content type 'application/x-gzip' length 400460 bytes (391 KB)
==================================================
downloaded 391 KB

* installing *source* package ‘curl’ ...
** package ‘curl’ successfully unpacked and MD5 sums checked
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/lauxxx/R/x86_64-pc-linux-gnu-library/3.3/curl’
Warning in install.packages :
  installation of package ‘curl’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpdoavNf/downloaded_packages’

Then I tried to install libcurl4-openssl-dev:

> install.packages("libcurl4-openssl-dev")
Installing package into ‘/home/lau/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘libcurl4-openssl-dev’ is not available (for R version 3.3.1)

Why? What is going wrong? How can I fix it?

It was ok when I was on Xubuntu 16.04. But now I am on Kubuntu 16.10.

Any ideas?

R Solutions


Solution 1 - R

libcurl4-openssl-dev is not a R package, but rather a linux library.

In a console type:

sudo apt-get install libcurl4-openssl-dev

Note: you need sudo powers.

Solution 2 - R

The Linux release is: CentOS Linux release 7.3.1611 (Core)

In my case, I was trying to install R package: devtools

------------------------- 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=...'

I checked $PATH, 'pkg-config' was in the PATH. But there is no libcurl.pc file in PKG_CONFIG_PATH (/usr/local/lib/pkgconfig/).

Here is how I solved the problem.

su
wget https://github.com/curl/curl/releases/download/curl-7_55_0/curl-7.55.0.tar.gz
./configure
make 
make install

After this, I saw libcurl.pc file in PKG_CONFIG_PATH (/usr/local/lib/pkgconfig/).

Solution 3 - R

I got this error on Ubuntu Server 18.04, despite already having the libcurl4-openssl-dev apt package installed. I had to look up where the package installs libcurl.pc to figure out the command to use:

wget <curl-package-address>
R CMD INSTALL --configure-vars='LIB_DIR=/usr/lib/x86_64-linux-gnu/pkgconfig' <curl-file.gz>

(Check the messages above the "ANTICONF ERROR" for the right file to download and install. For the questioner it was https://cran.rstudio.com/src/contrib/curl_2.3.tar.gz; mine was https://cloud.r-project.org/src/contrib/curl_4.3.tar.gz.)

Solution 4 - R

Just ran into this issue when using GitHub actions to run a R script on a cron schedule.

Popping sudo apt-get install libcurl4-openssl-dev into system() within the R file works. Much easier then setting up the bash command on the runner separately.

system("sudo apt-get install libcurl4-openssl-dev")

Solution 5 - R

------------------------- 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)

I ran into this issue when install an R package in Fedora Workstation 33. Following the hints, be sure to install libcurl-devel for the appropriate architecture, in this case libcurl-devel.x86_64:

sudo dnf install openssl-dev libcurl-devel.x86_64

Solution 6 - R

In my case of Ubuntu 18, none of these solutions worked from within Rstudio.

When I finally decided to run R from the command line, success -- I couldn't tell you which 'solution' was the key because by this point I've already tried all of them.

Note that if I try to run Rstudio again, any attempt to install will still fail.

Thus there may be some issue with Rstudio not inferring the environment properly.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRunView Question on Stackoverflow
Solution 1 - RGGambaView Answer on Stackoverflow
Solution 2 - Rxie186View Answer on Stackoverflow
Solution 3 - RAdam BradleyView Answer on Stackoverflow
Solution 4 - RPatrick LittleView Answer on Stackoverflow
Solution 5 - RdubkitView Answer on Stackoverflow
Solution 6 - Rsh37211View Answer on Stackoverflow