I'm rebuilding a custom R package which has, among other libraries, RcppArmadillo in the Depends row of the DESCRIPTION file.
I am running R 3.5.1. When I rebuild the package in RStudio, I get an error:
ERROR: dependency ‘RcppArmadillo’ is not available for package 'custom package name'
According to the R Packages book, packages under Depends/Imports must be installed when the package is rebuilt.
Solution
Use
devtools::install()instead.Explanation
According the RStudio website,
While
devtools::install()will install dependencies for you -- fromhelp("install.packages"):(emphasis added) this is not the case for
R CMD INSTALLalone (see?INSTALLfrom R orR CMD INSTALL --helpfrom the command line, etc. -- there is no mention of installing required dependencies).So, it appears the language
from Hadley's R Packages is a little specific; it does not pertain to using
R CMD INSTALL(which RStudio's build function apparently uses), but does work fordevtools::install(). It's a matter of personal taste, but honestly I highly recommend usingdevtoolsin your package development workflow.Example
I removed the package
rbenchmarkfrom my system viathen created a dummy package by
and edited the DESCRIPTION to put
rbenchmarkin Imports, so thatSOexampledepends on it. I added the following code inR/hello_world.R:I tried
R CMD INSTALL, but got the errorBut, if I try
devtools::install():