Home > Enterprise >  How Can I Identify non-R Dependencies in an R Package?
How Can I Identify non-R Dependencies in an R Package?

Time:04-17

I recently began using RStudio on a Linux system (Ubuntu 20.4) after having used it exclusively on Windows. I realized pretty quickly that a major difference between the two is that R will automatically locate and download non-R dependencies on Windows, but will not do so on Linux. Searching for the dependencies of any given package is easy enough and I'm comfortable with downloading non-R packages through the terminal. What I'm still struggling with, though, is identifying which packages are R packages and which packages are non-R packages and I haven't found a thread that outlines how to do this. I could certainly spend some time googling each, but, as an example, ggpubr alone has over 95 dependent packages that it uses. How can I efficiently determine which non-R dependencies a package needs?

CodePudding user response:

You need to read the DESCRIPTION file. It has a free-form field called SystemRequirements that describes non-standard requirements of the package.

You can see this on the CRAN page, or use the utils::packageDescription() function to see it if you can get the package installed. For example,

cat(utils::packageDescription("rgl")$SystemRequirements)
#> OpenGL, GLU Library, XQuartz (on OSX),
#> zlib (optional), libpng (>=1.2.9, optional), FreeType (optional),
#> pandoc (>=1.14, needed for vignettes; if not present,
#> markdown package will be used)

Created on 2022-04-16 by the reprex package (v2.0.1)

On CRAN this is shown on https://cloud.r-project.org/web/packages/rgl/index.html .

Many packages test for their dependencies and try to give helpful messages about how to install their dependencies if they aren't found. Others just fail to install, sometimes with fairly inscrutable error messages.

The reason this can be easier on Windows is that binary versions of packages are available for Windows. The nice people at CRAN find and install a large number of system dependencies on their own systems, then use those to build binary versions of the package that statically link the required libs. However, some packages can't statically link; they need DLLs of the libs to be installed on the system. Those ones can be quite hard for Windows users to install.

  • Related