Matt Tyers
Matt Tyers

Reputation: 2215

S4 exports specified in 'NAMESPACE' but not defined in package

I just finished some minor updates to an R package I've had on CRAN for a few years (haven't had to update in a while). My package passes Check on my local machine and on winbuilder, but it just bounced back from CRAN with the message

checking whether package 'riverdist' can be installed ... WARNING
Found the following significant warnings:
  Warning: S4 exports specified in 'NAMESPACE' but not defined in package 'riverdist'

I use roxygen2 to build my package NAMESPACE and don't have any S4 exports that I'm aware of.

Perhaps this might be related to changes in R version 4.0.0?

If anyone's encountered this error, I'd love to hear how you were able to resolve it. Thanks!

Upvotes: 5

Views: 683

Answers (2)

EdJo1924
EdJo1924

Reputation: 21

I received this message from rdevel

"This is a new check in R-devel. The NEWS say:

R CMD check etc now warn when a package exports non-existing S4 classes or methods, also in case of no "methods" presence

In your case, the NAMESPACE contains

exportClasses(classify)

exportClasses(gonad_mature)

exportClasses(morphMat)

but your package does not define these S4 classes.

You seem to instruct roxygen2 to create these invalid directives using @exportClass tags manually instead of just @export. Simply remove these wrong @exportClass tags from your source files and regenerate your NAMESPACE.

Best regards,

    Sebastian Meyer"

https://www.mail-archive.com/[email protected]/msg05436.html

Upvotes: 1

Pedro J. Aphalo
Pedro J. Aphalo

Reputation: 6508

Resolved. roxygen2's @exportClass adds to NAMESPACE exportClasses() which is intended for S4 classes. S3 classes do not need to be exported, only constructor and method functions should be exported, and this is done using @export. In my case deleting all @exportClass commands solved the problem as my package defines only S3 classes. So, indeed the WARNING message is correct in diagnosing S4 exports. Found answer with the help from a thread in R-package-devel mail list from yesterday.

In the case of my packages, the problem existed in only one package that the other 9 which were also triggering the warning depend on.

The WARNING is triggered only under r-devel (future R 4.1.0).

Upvotes: 2

Related Questions