Error in parse(outFile) : unexpected end of input - bug in package install, and how to fix

拟墨画扇 提交于 2020-06-29 04:30:12

问题


In trying to install my own package from GitHub I hit a problem that others have notified me about and I'd tried unsuccessfully to fix. I conclude that the package installer misinforms the user about the problem source, leading to fruitless searching for faults in working scripts.

install_github("SimonDedman/gbm.auto", force = TRUE)

(Screenshot so it lines up properly)


回答1:


One would logically conclude that the problem is... where the console says it is - the end of this file, gbm.valuemap_oldbkup.R. But I have scoured that file. It's fine. Reverted to a historical version (hence oldbkup filename) and that's fine too. BUT: instead of the error being in gbm.valuemap.R, now it's in gbm.valuemap_oldbkup.R. The difference? Oldbkup is now the last file in the list. So maybe the problem isn't that this specific file has an unclosed bracket... it's that there's an unclosed bracket somewhere in any of the previous files. Extending Duncan Murdoch's approach:

setwd("gbm.auto/R/") # goto package root
allfiles <- list.files() # list files
for (i in allfiles) {
  print(paste0(which(allfiles %in% i), "/", length(allfiles), " : ", i)) # counter
  text <- readLines(i)
  src <- srcfile(i)
  parse(text = text, srcfile = src)
}

I find that the problem is actually in gbm.auto.R. I scour that file, find the problem, fix it, retry install, works fine. I'll find out where to file this bug (install_packages, R, RStudio, other) and do so. In the meantime, hopefully this helps others.



来源:https://stackoverflow.com/questions/62364853/error-in-parseoutfile-unexpected-end-of-input-bug-in-package-install-and