【问题标题】:Building R package causes R to crash构建 R 包会导致 R 崩溃
【发布时间】:2017-11-21 18:53:53
【问题描述】:

当我尝试构建我创建的包时,我正在尝试诊断导致 R 崩溃的原因,但我不确定接下来要采取什么步骤。

我最初使用 RStudio 和 devtools 创建了这个包。在编写了几个函数后,我运行了devtools::document(),但这导致 RStudio 崩溃。当我重新打开项目时,document() 运行时没有崩溃,但随后 RStudio 在devtools::build() 之后崩溃。我重新打开了 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 文档 cmets 中是否存在导致崩溃的一个或多个函数的内容?

如果知道可能会有所帮助,包中包含一个文件 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、roxygen2 的 Macbook Pro 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: 

【问题讨论】:

  • 您使用的是 windows 并且您的用户名包含非 ASCII 字符?
  • 我在 Mac 上,我的用户名全是 ascii,没有空格或连字符。

标签: r crash package devtools


【解决方案1】:

只是为了解决这个问题:fst package 的开发人员 Marcus Klik 能够追踪并解决问题。 github issue page 有详细信息。向下滚动到靠近帖子末尾的 Marcus Klik 的评论,了解主要发现。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-07
    • 2020-12-05
    • 1970-01-01
    • 1970-01-01
    • 2013-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多