R Shiny Packaging: ERROR: unable to collate and parse R files for package ‘xx’

R Shiny Packaging: ERROR: unable to collate and parse R files for package ‘xx’

我正在编写一个闪亮的应用程序并将整个应用程序打包成一个包。我们称之为 app/package fruit

每次我对应用程序进行更改时,我都会执行以下操作:

library(devtools)
install()
library(fruit)
run_fruit_app()

我怀疑我在编辑时搞砸了一些东西,现在我 运行 install(), 弹出以下错误消息:

Running /Library/Frameworks/R.framework/Resources/bin/R CMD INSTALL \
  /var/folders/t6/v39yjp39xxxxxx/T//Rtmpxxx/fruit_0.1.0.tar.gz --install-tests 
* installing to library ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library’
* installing *source* package ‘fruit’ ...
** using staged installation
** R
Error in parse(outFile) : 
  /private/var/folders/t6/v39yjp39xxxxxx/T/Rtmpxxx/R.INSTALL11a89xxx/fruit/R/testing.R:1:1: unexpected symbol
1: library
    ^
ERROR: unable to collate and parse R files for package ‘fruit’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/fruit’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/fruit’
Error in (function (command = NULL, args = character(), error_on_status = TRUE,  : 
  System command 'R' failed, exit status: 1, stdout & stderr were printed
> .Last.error.trace 

 Stack trace:

 1. devtools:::install()
 2. pkgbuild::with_build_tools(required = FALSE, callr::rcmd("INSTALL",  ...
 3. callr::rcmd("INSTALL", c(install_path, opts), echo = !quiet,  ...
 4. callr:::run_r(options)
 5. base:::with(options, with_envvar(env, do.call(processx::run,  ...
 6. base:::with.default(options, with_envvar(env, do.call(processx::run,  ...
 7. base:::eval(substitute(expr), data, enclos = parent.frame())
 8. base:::eval(substitute(expr), data, enclos = parent.frame())
 9. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args = real_cmdargs,  ...
 10. base:::force(code)
 11. base:::do.call(processx::run, c(list(bin, args = real_cmdargs,  ...
 12. (function (command = NULL, args = character(), error_on_status = TRUE,  ...
 13. throw(new_process_error(res, call = sys.call(), echo = echo,  ...

 x System command 'R' failed, exit status: 1, stdout & stderr were printed 

潜在的错误来源是什么?我确实确保我没有忘记关闭括号,使用了错误的括号,或者在错误的工作目录中设置了东西。

非常感谢任何见解!

如评论中所述,我建议您这样做:

library(devtools)
check()
load_all()
run_fruit_app()

而不是每次需要检查时都安装软件包。 此外,check() 会告诉您代码是否存在问题。我猜你在代码的某处调用了 library()

最后,我也打包了一个闪亮的应用程序。以防万一你需要检查一些东西,这是回购 https://github.com/tomicapretto/sdeshiny

的 link

祝你好运!