建议 `parallel` 的包在 windows 中编译失败

Package that suggests `parallel` fails compile in windows

我正在开发一个 建议 R 的 parallel 包的包(所以我的 DESCRIPTION 有一个 Suggests: parallel (>= 1.13.1) 语句。它编译在 OSX 和 Linux 下很好,但在 windows 上构建时失败(使用 win-builder)。这是 win-builder 吐出的 install.log 的结尾:

*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
Error: package or namespace load failed for 'spectrolab' in 
library.dynam(lib, package, package.lib):
DLL 'parallel' not found: maybe not installed for this architecture?
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'd:/RCompile/CRANguest/R-devel/lib/spectrolab'

在此处查找 win-builder 的完整输出 https://win-builder.r-project.org/4k9QC0st397H/

只有一个函数尝试使用 parallel。它或多或少是这样的:

#' Smooth spline functions for spectra
#' ... roxygen stuff ...
#' @importFrom stats smooth.spline
#' @importFrom parallel detectCores mclapply
smooth.spectra = function(x, ...){

  p = requireNamespace("parallel", quietly = TRUE) && .Platform$OS.type != "windows"

  if(p){
     r = parallel::mclapply(x, stats::smooth.spline)
  } else {
     r = lapply(x, stats::smooth.spline)
  }
  r
}

知道问题出在哪里吗?

问题可能是这个包使用mclapply

r = parallel::mclapply(x, stats::smooth.spline)

mcapply 仅适用于 doMC

The doMC package acts as an interface between foreach and the multicore functionality of the parallel package, originally written by Simon Urbanek and incorporated into parallel for R2.14.0. The multicore functionality currently only works with operating systems that support the fork system call (which means that Windows isn't supported)

mclapplyparallel宇宙之下,但是

The doParallel package is a merger of doSNOW and doMC, much as parallel is a merger of snow and multicore.

这很可能是赢家小问题。我最近在 CRAN Windows 测试(与 win-builder 相同的设置)上观察到同样的情况,原因不明:

https://www.r-project.org/nosvn/R.check/r-devel-windows-ix86+x86_64/doFuture-00install.html

除非 win-builder 维护者 (Uwe Ligges) 亲自解决,否则您可以给他发一封电子邮件。