Skip to content
Prev 973 / 12125 Next

[R-pkg-devel] Handling Not-Always-Needed Dependencies?

You could abuse the LinkingTo: field of the DESCRIPTION file, to
specify 'packages you want installed alongside your package that you
won't necessarily use at runtime'. (It's possible that 'R CMD check'
might warn about strange usages of LinkingTo:, but I'm not sure)

You could also just place these packages in Suggests, but guard their
usages with a function that attempts to download, install and load
those packages. E.g. (pseudo-ish code)

    ensure_package_loaded <- function(package) {
      if (requireNamespace(package))
        return(TRUE)
      if (interactive())
       # prompt user to download + install package, then try to load again
      stop("routine requires package but is not installed")
    }

and use it as:

    uses_foo <- function() {
      ensure_package_loaded("foo")
      foo::bar()
    }

This would at least minimize the amount of time spent 'annoying' the
user re: installation of package dependencies (it would only happen
the first time they try to use those functions)

Overall, I think the best resolution here is through clever use of
Suggests + on-demand installation of required packages, rather than
adding another field to the DESCRIPTION file.

Cheers,
Kevin
On Tue, Aug 2, 2016 at 9:26 AM, Thomas J. Leeper <thosjleeper at gmail.com> wrote:

Thread (34 messages)

Thomas J. Leeper Handling Not-Always-Needed Dependencies? Aug 2 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 2 Joshua Ulrich Handling Not-Always-Needed Dependencies? Aug 2 Thomas J. Leeper Handling Not-Always-Needed Dependencies? Aug 2 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 2 Duncan Murdoch Handling Not-Always-Needed Dependencies? Aug 2 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 2 Kevin Ushey Handling Not-Always-Needed Dependencies? Aug 2 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 2 Thomas J. Leeper Handling Not-Always-Needed Dependencies? Aug 2 Duncan Murdoch Handling Not-Always-Needed Dependencies? Aug 2 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 2 Hadley Wickham Handling Not-Always-Needed Dependencies? Aug 2 Duncan Murdoch Handling Not-Always-Needed Dependencies? Aug 2 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 2 Duncan Murdoch Handling Not-Always-Needed Dependencies? Aug 2 Mark van der Loo Handling Not-Always-Needed Dependencies? Aug 3 Duncan Murdoch Handling Not-Always-Needed Dependencies? Aug 3 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 3 Mark van der Loo Handling Not-Always-Needed Dependencies? Aug 3 Thomas J. Leeper Handling Not-Always-Needed Dependencies? Aug 3 Uwe Ligges Handling Not-Always-Needed Dependencies? Aug 3 Uwe Ligges Handling Not-Always-Needed Dependencies? Aug 3 Uwe Ligges Handling Not-Always-Needed Dependencies? Aug 3 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 3 Uwe Ligges Handling Not-Always-Needed Dependencies? Aug 3 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 3 Uwe Ligges Handling Not-Always-Needed Dependencies? Aug 3 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 3 Duncan Murdoch Handling Not-Always-Needed Dependencies? Aug 3 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 3 Duncan Murdoch Handling Not-Always-Needed Dependencies? Aug 3 Dirk Eddelbuettel Handling Not-Always-Needed Dependencies? Aug 3 Duncan Murdoch Handling Not-Always-Needed Dependencies? Aug 4