[R-pkg-devel] How to (conditionally) use an archived package (without Suggests)?

Duncan Murdoch murdoch.duncan at gmail.com
Sun Feb 25 00:53:42 CET 2018


On 24/02/2018 6:45 PM, Marius Hofert wrote:
> Hi,
> 
> A package 'foo' uses a package 'bar' (in Imports). 'bar' has been
> archived and the maintainer of 'foo' was asked to fix the dependency
> on 'bar' according to WRE 1.1.3.1.
> 
> Working with 'bar::' everywhere (and requireNamespace("bar", quietly =
> TRUE)), as well as moving 'bar' from Imports to Suggests seems to work
> but is not accepted on submission. Removing 'bar' also from Suggests
> leads to

That should be fine, as long as your package still works when "bar" is 
unavailable.  That is, use requireNamespace in a conditional:

if (requireNamespace("bar", quietly = TRUE)) {
   # do the good stuff
} else {
   # do some less good substitute
}

without generating an error anywhere.


> 
> '::' or ':::' import not declared from: ‘bar’
> 'loadNamespace' or 'requireNamespace' call not declared from: ‘bar’

Right, you shouldn't refer to a package in code without mentioning it in 
the DESCRIPTION file.

> 
> Does this mean it is not possible to use 'bar' anymore in 'foo'?

I don't think so.  But CRAN policies may have changed...

Duncan Murdoch

> 
> These are (somewhat) related references I found:
> 1) https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Suggested-packages
> 2) https://stat.ethz.ch/pipermail/r-devel/2013-February/065947.html
>



More information about the R-package-devel mailing list