How to fix RCurl 'Cannot find curl-config' or 'checking for curl-config... no'

Problem:

You want to install RCurl using

Rscript -e "install.packages('RCurl')"

but you see an error message like

Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/RCurl_1.98-1.2.tar.gz'
Content type 'application/x-gzip' length 699583 bytes (683 KB)
==================================================
downloaded 683 KB

* installing *source* package ‘RCurl’ ...
** package ‘RCurl’ successfully unpacked and MD5 sums checked
** using staged installation
checking for curl-config... no
Cannot find curl-config
ERROR: configuration failed for package ‘RCurl’
* removing ‘/usr/local/lib/R/site-library/RCurl’

The downloaded source packages are in
 ‘/tmp/RtmpSVQKd1/downloaded_packages’
Warning message:
In install.packages("RCurl") :
  installation of package ‘RCurl’ had non-zero exit status

Solution

You need to install the curl development headers on your machine. RCurl complains that it can’t find those development headers.

On Ubuntu/debian, use

sudo apt -y install libcurl4-openssl-dev