Cran R CMD CHECK with nonstandard system dependencies

I'm developing an R package which handles I/O between a commandline program and an R session. The commandline software requires the user to manually install the software, so installing the package will not ensure the software exists. I would like for the package to eventually be available on CRAN or Bioconductor, so I'm struggling to figure out the best practices for writing vignettes and examples without causing errors. For example, I know that when writing vignettes, even though vignettes are not rebuilt, the code has to run. If the check server is missing the software dependency which will cause my functions to error, will this fail checks? Do I need to wrap each of these code chunks with purl = FALSE? How do other packages with system-level dependencies handle this issue?

1 Like

I think you probably need to prevent code from the vignettes, tests and examples to be run. Now, as to how to do that there are several solutions (that I know of).

Note I have no idea how Bioconductor handles missing system requirements, whereas for CRAN it's probably easier to escape code (on CI and R-hub your config/DESCRIPTION should help install the program).

I'm curious to see what others answer, and I guess you already know part of the things I'm writing. :slightly_smiling_face:

Knowing whether the software is installed

It makes sense to define a function that'd return TRUE or FALSE depending on whether the commandline program could be found/started. Then it could be used to skip stuff when checking the package, but also in your functions wrapping the program, to give an informative error message to the user telling them to first install the program.

Vignettes

```{r, echo = FALSE}
NOT_CRAN <- identical(tolower(Sys.getenv("NOT_CRAN")), "true")
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  purl = NOT_CRAN,
  eval = NOT_CRAN
)
  • You could skip having vignettes and make them "articles" instead, that are present in a pkgdown site but not on CRAN/Bioconductor. googledrive setup. No vignette, no vignette problem. :wink:

(I'm working on a blog post about vignettes for the R-hub blog so I like your question!)

Examples

  • You could skip them conditionally on the software being installed. I.e. the example code would be
if (cool_tool_is_installed() ) {
  cool_package_do()
} 

Tests

Packages with a similar challenge

  • I've mostly given examples of packages whose problem isn't "software available" but "token available" which in a way is similar.
  • I'm thinking of the beastier package, on CRAN, that has a function for installing a software (to an app dir), and one for checking its installation, is_beast2_installed().
2 Likes

This is great, @maelle, and kind of what I was converging on, so it's really nice to see other examples and that there is some consensus on how to handle these issues. The if/else chunks should have occurred to me for my examples, but the precompiling and NOT_CRAN solutions are really clever, and will solve this (and an issue with long-running vignettes!).

Thanks for a thorough response!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.