构建R包会导致R崩溃

时间:2017-11-21 18:53:53

标签: r crash package devtools

当我尝试构建我已经创建的软件包时,我试图诊断导致R崩溃的原因,我不知道下一步要采取什么措施。

我最初使用RStudio和devtools创建了包。在编写了几个函数之后,我运行了devtools::document(),但是这导致了RStudio崩溃。当我重新打开项目时,document()在没有崩溃的情况下运行,但是在devtools::build()之后RStudio崩溃了。我重新打开了RStudio,这次build()运行没有错误,我可以点击Install and Restart来安装软件包。点击Install and Restart后,RStudio有时会崩溃,有时甚至不会。

我决定在不使用RStudio的情况下直接运行R来尝试builddocument命令。我从项目目录中删除了man文件夹和NAMESPACE文件。然后,在将工作目录设置为包的目录之后,我运行了devtools::document(),它运行时没有错误,并生成了man文件夹和NAMESPACE文件。然后我跑了devtools::build()撞毁了R.坠机消息如下。但是,当我重新启动R并再次运行build()时,它运行时没有错误。然后我从命令行运行R CMD INSTALL并安装了包,没有错误。

我不确定下一步要采取什么措施。当我在R脚本中直接创建和使用它们时,包中的所有函数都会运行而不会出错。 roxygen文档评论中是否有针对导致崩溃的一个或多个功能的内容?

如果知道可能有帮助,该软件包包含一个文件imports.r,其中包含以下导入:

#' @importFrom fst read.fst
#' @importFrom lubridate today
#' @import readr
#' @import readxl
#' @import dplyr
NULL

我可以提供其他信息,例如包裹的详细信息和代码,崩溃日志等。我在运行Sierra(10.12.6),R 3.4.2,devtools 1.13.3.9000的Macbook Pro上运行,roxygen2 6.0.1和RStudio 1.1.383。

这是第一次运行build()后来自R的崩溃消息:

 *** caught illegal operation ***
address 0x7fff9f32eae4, cause 'illegal opcode'

Traceback:
 1: process_initialize(self, private, command, args, commandline,     stdout, stderr, cleanup, echo_cmd, windows_verbatim_args,     windows_hide_window)
 2: .subset2(public_bind_env, "initialize")(...)
 3: process$new(command, args, commandline, echo_cmd = echo_cmd,     windows_verbatim_args = windows_verbatim_args, windows_hide_window = windows_hide_window,     stdout = "|", stderr = "|")
 4: run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout),     stderr_line_callback = real_callback(stderr), stdout_callback = real_block_callback,     stderr_callback = real_block_callback, echo_cmd = echo, echo = show,     spinner = spinner, error_on_status = fail_on_status, timeout = timeout)
 5: force(code)
 6: with_envvar(env, run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout),     stderr_line_callback = real_callback(stderr), stdout_callback = real_block_callback,     stderr_callback = real_block_callback, echo_cmd = echo, echo = show,     spinner = spinner, error_on_status = fail_on_status, timeout = timeout))
 7: eval(substitute(expr), data, enclos = parent.frame())
 8: eval(substitute(expr), data, enclos = parent.frame())
 9: with.default(options, with_envvar(env, run(bin, args = real_cmdargs,     stdout_line_callback = real_callback(stdout), stderr_line_callback = real_callback(stderr),     stdout_callback = real_block_callback, stderr_callback = real_block_callback,     echo_cmd = echo, echo = show, spinner = spinner, error_on_status = fail_on_status,     timeout = timeout)))
10: with(options, with_envvar(env, run(bin, args = real_cmdargs,     stdout_line_callback = real_callback(stdout), stderr_line_callback = real_callback(stderr),     stdout_callback = real_block_callback, stderr_callback = real_block_callback,     echo_cmd = echo, echo = show, spinner = spinner, error_on_status = fail_on_status,     timeout = timeout)))
11: run_r(options)
12: callr::rcmd_safe(..., env = env)
13: with_build_tools(callr::rcmd_safe(..., env = env), required = required)
14: rcmd_build_tools(cmd, c(path, args), wd = out_dir, show = !quiet,     echo = !quiet, fail_on_status = TRUE, required = FALSE)
15: force(code)
16: withr::with_temp_libpaths(rcmd_build_tools(cmd, c(path, args),     wd = out_dir, show = !quiet, echo = !quiet, fail_on_status = TRUE,     required = FALSE))
17: pkgbuild::build(path = path, dest_path = dest_path, binary = binary,     vignettes = vignettes, manual = manual, args = args, quiet = quiet,     ...)
18: devtools::build()

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 

1 个答案:

答案 0 :(得分:0)

关闭此问题:fst package的开发人员Marcus Klik能够追踪并解决问题。 github issue page有详细信息。在主题结尾附近向下滚动到Marcus Klik的评论。