When building a package, I got the error
Error in namespaceExport(ns, exports) :
undefined exports: FooBarBaz
What does this mean, and how do I fix it?
When building a package, I got the error
Error in namespaceExport(ns, exports) :
undefined exports: FooBarBaz
What does this mean, and how do I fix it?
Be careful not to have any commented lines that begin with an apostrophe!
By bad luck, inside my function I had commented out a line that began with an apostrophe (in front of 'Battlestar Galactica' in my fake example) so it look like this:
This really screwed up roxygen2 v 6.0.1 since it did not signal any errors and this is what it put into my NAMSEPACE file:
Not only was my desired export myFavoriteSciFiShows missing but two erroneous ones were added. These erroneous ones can result in undefined exports.
I had a very stupid typo: in roxygen2 skeleton, I copied what was meant to go into
#' @return
field, to@export
.Should have been:
Instead, I had:
This error occurs when you try to export an object that doesn't exist. That is, the package
NAMESPACE
file contains the linebut
FooBarBaz
doesn't exist in the package.One case where this error can occur is when you are trying to create a common help page for several functions using
roxygen2
. In the example below,f
andg
are related functions to be documented in theWidgetUtils
page.The mistake in this code chunk is the inclusion of the
@export
tag in theWidgetUtils
roxygen block. This tells roxygen to generate the export line in theNAMESPACE
file, but its value isNULL
, so there is nothing to export. By removing the@export
line, so the code will work correctly.I removed a function, and roxygen2 didn't seem to remove it from the NAMESPACE file. Go in there and delete that line manually and it will fix the error