Skip to content

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

3 messages · Marius Hofert, Duncan Murdoch, Dirk Eddelbuettel

#
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

'::' or ':::' import not declared from: ?bar?
'loadNamespace' or 'requireNamespace' call not declared from: ?bar?

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

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

Thanks & cheers,
Marius
#
On 24/02/2018 6:45 PM, Marius Hofert wrote:
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.
Right, you shouldn't refer to a package in code without mentioning it in 
the DESCRIPTION file.
I don't think so.  But CRAN policies may have changed...

Duncan Murdoch
#
On 25 February 2018 at 00:45, Marius Hofert wrote:
| 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
| 
| '::' or ':::' import not declared from: ?bar?
| 'loadNamespace' or 'requireNamespace' call not declared from: ?bar?
| 
| Does this mean it is not possible to use 'bar' anymore in 'foo'?

Your title says "conditionally".

Does your code actually behave conditionally, ie does foo check if bar is
available, and only use its code if it is?

One additional difficulty may be that even for Suggests, it still has to be
accessible "somewhere" .  And "archived" is not.  You could just move bar
onto a drat repo you set yp -- we have done the same for data packages and
have a R Journal paper describing it:

   https://journal.r-project.org/archive/2017/RJ-2017-026/index.html

Hth, Dirk