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.
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
- You could pre-compute vignettes following the approach described by Jeroen Ooms in an rOpenSci tech note.
- You could indeed use
purl
&eval
. See @jimhester's comment about global knitr options, and this GitHub thread. A chunk could be line the one fromgooglesheet
```{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.
(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()
}
- It'd be less safe/easy to try and skip examples based on donttest/dontrun, since rules change
Tests
- Interesting setup with a custom skipper, described in a
gargle
vignette by @jennybryan. Instead ofdrive_has_token()
you'd usecool_tool_installed()
.
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()
.