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?
This error occurs when you try to export an object that doesn't exist. That is, the package NAMESPACE
file contains the line
export(FooBarBaz)
but 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
and g
are related functions to be documented in the WidgetUtils
page.
#' Widget-related functions #' #' Utility functions to assist working with widgets. #' @param x An input. #' @return A value. #' @name WidgetUtils #' @export NULL #' @rdname WidgetUtils #' @export f <- function(x) { x + 1 } #' @rdname WidgetUtils #' @export g <- function(x) { x - 1 }
The mistake in this code chunk is the inclusion of the @export
tag in the WidgetUtils
roxygen block. This tells roxygen to generate the export line in the NAMESPACE
file, but its value is NULL
, so there is nothing to export. By removing the @export
line, so the code will work correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With