Ray
Ray

Reputation: 108

R package versioned dependencies

I'm updating an R package and have two specific dependencies

httr (>= 0.6.1),
jsonlite (>= 0.9.14)

If these are not met the package will not function. I can see that if I put them both in Depends these version restrictions will be enforced by R. If I put them under Imports it appears they are not. There is no need for the packages to be put in Depends, I do not need them attached, and I know it is bad practice to do so.

Is it expected that Imports does not enforce version restrictions? Would it be kosher to leave the packages in Imports and have the .onLoad function check for out of date dependencies?

Upvotes: 2

Views: 86

Answers (1)

Martin Morgan
Martin Morgan

Reputation: 46856

Writing R Extensions section 1.1.3 says

The ‘Imports’ field ... Version requirements can be specified and are checked when the namespace is loaded (since R >= 3.0.0).

So it sounds like the lack of version checking is a bug and should be reported to the R-devel mailing list or bug tracker.

Hmm, I think the check is enforced when the namespace is loaded, e.g., import(httr) in the NAMESPACE file. If your code were to use httr::foo() without ever explicitly importing from httr, then there would be no check, or perhaps a check at run time. So again it seems like a bug, even if consistent with the documentation ('checked when the namespace is loaded').

Upvotes: 1

Related Questions