0

I'm putting together an R package, and made some small edits to the DESCRIPTION file and create a package document. I wanted to view the changes and updated the documentation then hit "Build & Reload" and I'm suddenly getting this error:

Error in errmsg("invalid value of ", field, " field in DESCRIPTION") : could not find function "errmsg"

What could cause this error? How would I go about troubleshooting?

Phil
  • 7,287
  • 3
  • 36
  • 66
  • Can you back out the changes to DESCRIPTION and reintroduce them one at a time until it breaks ? You would have to do "Build & Reload" (or "Clean and Rebuild"). – steveb May 17 '17 at 22:05
  • @steveb Very strange. As you suggested, I backed out, then reintroduced the changes one at a time. All changes are now present, and the error is no longer occurring. – Phil May 17 '17 at 22:10
  • A couple of things I found useful when preparing to build a package (e.g. testing it before building) is to clean up the environment `rm(list=ls())`. Running "Clean and Rebuild" (which should restart R, which is necessary). Also, sometimes quitting R Studio and relaunching has been necessary (I think). Either way, I am glad to hear it works. – steveb May 17 '17 at 22:13
  • The only place I could find a similar `errmsg()` function was in this rather old code: https://github.com/hadley/packman/blob/master/old/cmd-install.r. You're not using that, or something like it? It's a mysterious error. – neilfws May 17 '17 at 22:18
  • 1
    @neilfws I'm not. I noticed this page as well while googling for a potential cause, but didn't know what to make of it. – Phil May 17 '17 at 22:24

1 Answers1

0

I encountered this same error message, and it seems to be caused by a bug in R 3.4.2 tools:::.install_packages(), the R function that R CMD INSTALL invokes (which in turn, is invoked by devtools).

When it finds a syntax error in one of the DESCRIPTION fields, it tries to print out a message saying which field has the problem, like "invalid value of LazyData field in DESCRIPTION". But the error handler itself errors out, and instead you get that unhelpful message about the errmsg() function.

I've just emailed my bug report to R-devel, but for anyone else comes across this page via Google, the workaround is to find and fix the underlying syntax error in your DESCRIPTION file. In my case, the problem was that I had LazyData: true, (with a trailing comma) instead of LazyData: true.

Aaron Wells
  • 1,135
  • 7
  • 5