The DESCRIPTION
file in R packages has several ways of specifying dependencies, eg Depends
, Suggests
and Imports
. Which one should I use to specify a dependency that is optional once the package is installed, but required for running R CMD check
?
In my particular case I am using testthat
to run some tests automatically when R CMD check
is run, but during "normal" operation, testthat
is not required. The answer to this question suggests that testthat
should be in Suggests
, but is that enough to ensure that R CMD check
runs correctly?
What I would like to see, if it exists, is a field where I can speciy dependencies that are required only to run R CMD check
, which should fail with an appropriate error message if these packages are not available.
Yes, you should put them in the Suggests
field. The only other thing required for R CMD check
to run successfully is to ensure the packages in the Suggests
field are installed in a location that will be found by R CMD check
.
If they're not available, you can set the environment variable _R_CHECK_FORCE_SUGGESTS=false
and R CMD check
will run, with a "NOTE" about the missing suggested packages.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.