R语言 在`tempfile()`中出错:无法在单元测试期间找到未使用的临时文件名

qv7cva1a  于 2023-10-13  发布在  其他
关注(0)|答案(1)|浏览(84)

当运行一些包的单元测试时(例如,dplyr),测试失败,并出现以下错误:

Error in `tempfile()`: cannot find unused tempfile name
Backtrace:
     ▆
  1. └─testthat::expect_snapshot(desc(mean), error = TRUE) at test-desc.R:2:2
  2.   ├─testthat:::with_is_snapshotting(...)
  3.   └─testthat:::verify_exec(quo_get_expr(x), quo_get_env(x), replay)
  4.     ├─withr::local_pdf(tempfile())
  5.     │ └─withr:::pdf_dev(...)
  6.     │   └─grDevices::pdf(...)
  7.     │     └─grDevices:::checkIntFormat(file)
  8.     │       └─base::gsub("%%", "", s, fixed = TRUE)
  9.     │         └─base::is.factor(x)
 10.     └─base::tempfile()

这似乎是一个操作系统级配置或R insert配置问题,因为它不会发生在我的笔记本电脑或其他可用的服务器上。有一个线程从2005年提到这个问题时,使用swave,但没有真实的解决方案。下面是sessionInfo、platform_info和ulimit信息。

R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.8 (Ootpa)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.15.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_1.1.2    testthat_3.1.9

loaded via a namespace (and not attached):
 [1] pillar_1.9.0      compiler_4.1.3    dbplyr_2.3.2      lobstr_1.1.2     
 [5] prettyunits_1.1.1 tools_4.1.3       bit_4.0.5         pkgbuild_1.4.1   
 [9] pkgload_1.3.2     memoise_2.0.1     RSQLite_2.3.1     evaluate_0.21    
[13] lifecycle_1.0.3   tibble_3.2.1      pkgconfig_2.0.3   rlang_1.1.1      
[17] cli_3.6.1         DBI_1.1.3         rstudioapi_0.14   fastmap_1.1.1    
[21] withr_2.5.0       generics_0.1.3    desc_1.4.2        vctrs_0.6.3      
[25] bit64_4.0.5       rprojroot_2.0.3   tidyselect_1.2.0  glue_1.6.2       
[29] R6_2.5.1          processx_3.8.1    fansi_1.0.4       waldo_0.5.1      
[33] blob_1.2.4        callr_3.7.3       purrr_1.0.1       magrittr_2.0.3   
[37] ps_1.7.5          ellipsis_0.3.2    utf8_1.2.3        stringi_1.7.12   
[41] cachem_1.0.8      crayon_1.5.2      brio_1.1.3
> sessioninfo::platform_info()
 setting  value
 version  R version 4.1.3 (2022-03-10)
 os       Red Hat Enterprise Linux 8.8 (Ootpa)
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/New_York
 date     2023-09-25
 rstudio  2023.03.0+386.pro1 Cherry Blossom (server)
 pandoc   2.0.6 @ /usr/bin/pandoc
[dplyr]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 502453
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 4096
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 502453
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

我尝试使用不同的临时目录,以确保空间不是一个问题。我还比较了系统设置,以确保用户对打开文件的限制在此系统和不发生此错误的系统之间是相同的。
我也试过删除tempdir中的所有内容,建议如下:'Warning: Error in tempfile: cannot find unused tempfile name' when rendering multiple R Markdowns但没有用。

kqlmhetl

kqlmhetl1#

原来这是testthat v3.1.9中的一个bug,已经用following PR修复了。

相关问题