Package that suggests `parallel` fails compile in windows

148 views Asked by At

I am developing a package that suggests R's parallel package (So my DESCRIPTION has a Suggests: parallel (>= 1.13.1) statement. It compiles fine under OSX and Linux but fails when building on windows (using win-builder). Here is the end of the install.log that win-builder spits out:

*** 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'

Find the full output from win-builder here https://win-builder.r-project.org/4k9QC0st397H/

There is only one function that tries to use parallel. It goes more or less like this:

#' 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
}

Any ideas of what the problem is?

2

There are 2 answers

4
HenrikB On BEST ANSWER

It's most likely a win-builder hiccup. I've just recently observed the same on CRAN Windows tests (same setup as win-builder) for no good reasons:

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

Unless win-builder maintainer (Uwe Ligges) gets to it himself, you could drop him an email.

3
CPak On

The problem could be that this package uses mclapply

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

mcapply only works under 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)

mclapply is under the parallel universe, but

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