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!

Community
  • 1
  • 1
random_forest_fanatic
  • 1,232
  • 1
  • 12
  • 30
  • `MCLE`, `defineFunctions` and `naiveMLE` are your own functions, right? –  Feb 16 '16 at 05:58
  • @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. – random_forest_fanatic Feb 16 '16 at 06:14

1 Answers1

6

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

Francesco Grossetti
  • 1,555
  • 9
  • 17
  • 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. – Waldir Leoncio May 06 '19 at 08:45
  • 1
    Thank you so much for sharing ! I have been banging my head for 1 day+ on this... – cbo Mar 23 '20 at 10:16
  • I am sorry, if you find my answer correct, could you please accept it as it is and flag it? Thanks – Francesco Grossetti Apr 28 '20 at 18:40
  • 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. – dcruvolo Jul 29 '20 at 15:14
  • Thanks! Can you check the answer as the solution pls. – Francesco Grossetti Jul 30 '20 at 16:54
  • 1
    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. – Steven Lockton Jun 04 '21 at 22:09
  • @random_forest_fanatic can you please flag the answer as correct if it solved your problem? It's been a while now. Thanks – Francesco Grossetti Jul 19 '21 at 13:41