install.packages('curl') fails because libcurl is not found on Ubuntu
Configuration failed because libcurl was not found.Short answer
R packages that bind to curl compile against the libcurl headers, which the normal runtime library does not include. On Ubuntu and Debian install libcurl4-openssl-dev, then retry the install. If that is already present, check that the installed libcurl meets the version the package asks for.
Fix it fast
1Find out which cause you have
Ask the system whether the libcurl development files are there. If curl-config is missing or reports an old version, the build cannot find what it needs.
curl-config --version dpkg -l | grep libcurl2Match what you see, then jump to its fix
What does the error look like?
Configuration failed because libcurl was not found.the R package install stops during configure and names libcurl
Cause 1 of 2
The libcurl development package is not installed
1Check
The runtime library only lets programs run. Building a package needs the headers and curl-config, which sit in the -dev package.
dpkg -s libcurl4-openssl-dev | grep Status2Fix
The curl package lists libcurl4-openssl-dev as the Debian package to install. Install it and retry.
sudo apt update
sudo apt install libcurl4-openssl-dev3Verify
The package builds, and the load test passes.
curl-config --version
Rscript -e 'install.packages("curl"); library(curl)'Confirmed by cran.r-project.org
Cause 2 of 2
The installed libcurl is older than the package requires
1Check
The curl package states libcurl 7.73 or newer. An old distribution release can ship an older library, so the configure test fails even with the dev package present.
curl-config --version
lsb_release -ds2Fix
Upgrade the system packages, or move to a distribution release that ships a newer libcurl. Pick an older curl package version from the CRAN archive only when you cannot upgrade.
sudo apt update
sudo apt upgrade3Verify
curl-config reports a version at or above the requirement, and the install succeeds.
curl-config --version
Rscript -e 'install.packages("curl")'Confirmed by cran.r-project.org
How do I stop it coming back?
- Install system libraries for R packages from the package's SystemRequirements field before running install.packages.
- Put the -dev packages you need in the Dockerfile or provisioning script, not in a hand-run fix.
- Keep Ubuntu on a supported release so system libraries meet current CRAN requirements.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Servers
dnf cannot install MySQL on Amazon Linux 2023
dnf cannot find a mysql-server package on Amazon Linux 2023
Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.
3 causes, each with a fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
Apache warns that a ${VAR} config variable is not defined
${VAR} left unchanged in the configuration, with a warning in the error log
Apache expands ${VAR} from Define or from the shell environment that exists when the server starts.
3 causes, each with a fix