Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does R check for system external dependencies when installing an R package?

Tags:

r

For instance, while trying to install the R package curl as a dependency of usethis:

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

R detects that I don't have libcurl installed. At what level is this external dep. specified? I know that external dependencies can be indicated in the DESCRIPTION file, and indeed curl's pkg DESCRIPTION file does contain:

SystemRequirements: libcurl: libcurl-devel (rpm) or libcurl4-openssl-dev (deb).

But is that line what allowed R to detect the missing dependency and print that error? Can't be, right? How could it? So, how is R doing it?

like image 350
plant Avatar asked Oct 08 '19 17:10

plant


People also ask

How does install packages work in R?

Type “install. packages(“gplots”)” and then press the Enter/Return key. If you have already loaded a package from a server in the R session, then R will automatically install the package. If not, R will automatically prompt you to choose a mirror.

How do you check if R is installed correctly?

If you are using a Windows PC, there are two ways you can check whether R is already installed on your computer: Check if there is an “R” icon on the desktop of the computer that you are using. If so, double-click on the “R” icon to start R.

What are dependencies in R package?

A dependency is a code that your package needs to run. Dependencies are managed by two files. The DESCRIPTION manages dependencies at the package level; i.e. what packages needs to be installed for your package to work. R has a rich set of ways to describe different types of dependencies.


1 Answers

Briefly:

  1. This is all in Writing R Extension.
  2. In short, it doesn't i.e. R does not help you. See below.
  3. CRAN (and Bioconductor) package dependencies can be declared.
  4. For everything else you can only approximate via SystemRequirements in DESCRIPTION
  5. This is not a solved or solvable problem of all depends across all operating systems
  6. So no other language has it either.
  7. What one can get is a package manager in a 'vertical' stack -- say brew or apt. That is pretty good, but it also does not work at the CRAN source level.
  8. So all one can do is, as you show, invoke something executable called configure to test if resources are present, and to abort with clear errors if not.
  9. For the package you show, that test code in configure is here.
  10. There is a sibbling Windows version too.
like image 55
Dirk Eddelbuettel Avatar answered Sep 20 '22 02:09

Dirk Eddelbuettel