R CMD check fails with "undefined exports"
Asked Answered
S

1

5

I'm trying to create an R package but I keep getting the error:

Error in namespaceExport(ns, exports) : 
  undefined exports: MCLE, defineFunctions, naiveMLE

when running R CMD check on my package. I'm using roxygen2, and the three functions listed in the error message are the three with @export tags. I've checked similar problems/solutions on stack overflow:

but none of these seem to resolve my problem (I'm not using <<-, I don't export any functions with a common help page, and the issue isn't with ggplot2 or a different R package on CRAN).

I've built the package after deleting the NAMESPACE file, and it built successfully. I've also confirmed that the package has the functions listed as "undefined," and I don't know what else to check!

Stroller answered 16/2, 2016 at 5:44 Comment(2)
MCLE, defineFunctions and naiveMLE are your own functions, right?Delldella
@Pascal Yes, exactly. Sorry, I just now realized that I mentioned they have export tags but I should have noted that they are also functions in my package.Stroller
C
7

I had a very similar problem. Did you check your .Rbuildignore file? It could be related to regular expression matches with the functions you want to export.

I was trying to exclude from the build the directory "HTLM_downloads" by putting the name inside .Rbuildignore. Unfortunately this does not work since it ignores every file containing the word "html" (HTML). Not even an @export solved the problem. I needed to anchor the expression by putting ^HTML_downloads$.

You can easily exclude files and/or directory by using devtools::use_build_ignore("file/dir you want to ignore").

Hope this helped

I'd like to thank @hadley for his kind and neat support

Collectanea answered 16/2, 2017 at 7:51 Comment(7)
Thank you for this. I had "foo" in .Rbuildignore because I wanted to exclude a folder with that name, but it ended up masking a couple of exported functions that also had "foo" in the name. Writing "foo/" instead made sure .Rbuildignore ignored the folder and left the functions alone.Argentous
Thank you so much for sharing ! I have been banging my head for 1 day+ on this...Labialized
I am sorry, if you find my answer correct, could you please accept it as it is and flag it? ThanksCollectanea
Incredibly helpful! I had no idea that this could happen. I had a few custom regexpr for file extensions, which I guess caught all functions in my package. For me, I erased all patterns in the .Rbuildignore file and explicitly named the files and paths that I wanted to ignore.Daisy
Thanks! Can you check the answer as the solution pls.Collectanea
I had a similar problem, and my brand new package had my /R folder in .Rbuildignore (smh). Removed it from the file and all builds nicely.Velites
@Stroller can you please flag the answer as correct if it solved your problem? It's been a while now. ThanksCollectanea

© 2022 - 2024 — McMap. All rights reserved.