81

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’
(as ‘lib’ is 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?

Phil
  • 7,287
  • 3
  • 36
  • 66
Run
  • 54,938
  • 169
  • 450
  • 748
  • I had the same problem and it was a confusing b/c downloading the `libcurl4` library from ubuntu.com as a deb and installing via Eddy did not resolve my problem. However installing it via the console (as suggested in the accepted answer) did work. I guess I don't understand Linux enough to know why these might differ. – DirtStats Sep 29 '20 at 18:50

7 Answers7

144

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.

zx8754
  • 52,746
  • 12
  • 114
  • 209
GGamba
  • 13,140
  • 3
  • 38
  • 47
  • People who are having trouble running R 3.5.2 on Ubuntu 18.04 and not able to install any packages which show error: "Error in install.packages : This version of R is not set up to install source packages If it was installed from an RPM, you may need the R-devel RPM" this is the same error. The main error is that installing r-base removes libcurl3 and installing libcurl3 removes r-base packages, which leads to above error. Do the command GGamba suggested and you should be fine. Thanks GGamba once again, I spent almost an hour troubleshooting this error. – Parth Patel Feb 24 '19 at 03:20
  • @ParthPatel I am trying this with Travis CI (see [here](https://stackoverflow.com/questions/56345639/error-required-package-curl-not-found-please-run-install-packagescurl-exe)) - I have tried adding `sudo apt-get install libcurl4-openssl-dev` to `.travis.yml` and I can see in the build logs that it seems to run, but the original error persists. Any ideas? – stevec May 28 '19 at 15:56
  • 2
    To install all `tidyverse` dependancies I also needed to install libssl, I'm running Ubuntu 20.04. So for that I typed: `sudo apt-get install libssl-dev` – DirtStats Sep 29 '20 at 18:46
  • after install `libssl-dev` or `libcurl14-openssl-dev` I cannot install `tidyverse`: `# Rscript -e 'install.packages(c("tidyverse"))'` I got `ERROR: R_HOME ('/usr/lib/R') not found` Did somebody meet with that kind of error? – 32cupo Feb 04 '22 at 11:39
  • Thanks, this solved my problem resolving a curl dependency when installing httr, RCurl and plotly. My Ubuntu 18.04 was missing the dev version of the library. `R version 4.2.2 Patched (2022-11-10 r83330) -- "Innocent and Trusting"` and `Ubuntu 20.04.5 LTS` – Pablo Adames Jan 10 '23 at 16:18
28

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

zx8754
  • 52,746
  • 12
  • 114
  • 209
xie186
  • 487
  • 4
  • 9
  • 1
    Installing libcurl4-openssl-dev works, but it cannot work simultaneously with nodejs, npm, etc. This method works with the mentioned applications. – Naveen Mathew Jan 21 '19 at 18:50
  • This solved it for me. Ubuntu 18.04, inside a conda environment, `libcurl4-openssl-dev` was installed but somehow R was not finding it. Manually compiling libcurl solved the issue. – fridaymeetssunday Aug 01 '19 at 12:23
  • This worked for me too. But I kept getting the error Error in curl::new_handle() : An unknown option was passed in to libcurl when I tried retrieving data from a URL. – KarthikS Mar 25 '20 at 23:15
  • This works as an interim solution, but library(RCurl) and library(curl) still identifies the older version of curl and not the new versions compiled from source using procedure above. See [here](https://stackoverflow.com/questions/51571901/how-to-update-rcurl-and-curl-to-the-version-on-the-host-machine) – KarthikS Mar 26 '20 at 05:23
  • 1
    This solution works in Ubuntu 18.04. I downloaded curl 7.72.0 (last version as of September 8th 2020). I had to run make install with sudo powers – antortjim Sep 08 '20 at 15:06
  • yum install libcurl-devel works fine – Digin Dominic Apr 06 '22 at 10:28
10

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")
Patrick Little
  • 101
  • 1
  • 3
  • 1
    In case anyone else finds this from a search engine, this is also what I needed for RStudio inside Azure Machine Learning. – Brian Jul 20 '21 at 16:12
8

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

Adam Bradley
  • 1,575
  • 15
  • 14
  • I noticed this as well. there is no `libcurl.pc` in any of the packages I installed for `libcurl` variants. – ryeager May 21 '20 at 02:07
  • Thanks, this is the only thing that worked for me on Ubuntu server 20.04. Seems like R can't find `libcurl` by itself after installation. – Cameron Hyde Jan 10 '22 at 05:34
  • I had the same issue for `install.packages ('tidyverse'), R console showed the following message `-- [ANTICONF] -- Try installing: * deb: libfreetype6-dev libharfbuzz-dev libfribidi-dev libjpeg-dev (Debian, Ubuntu, etc)' -- [ERROR MESSAGE] --` This was the error I got for Ubuntu 22.10 on MacBook Pro9.2. By installing `ibharfbuzz-dev` `libfribidi-dev` 'libjpeg-dev` `libfreetype6-dev` from the terminal (Ctrl+Alt+t). The key point is to look for what libs are missing from the ANTICONF message and install those. – Saneesh C S May 13 '23 at 12:03
5
------------------------- 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
myeongkil kim
  • 2,465
  • 4
  • 16
  • 22
dubkit
  • 51
  • 1
  • 1
0

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.

sh37211
  • 1,411
  • 1
  • 17
  • 39
0

If you are using conda environment, the following command will resolve the issue.

conda install -c conda-forge r-curl
Amina LEM
  • 9
  • 1