Repository navigation
Description
This originates from #219, which has become quite long and added several manually solutions to the more precise question raised here: Should multisession workers inherit .libPaths() from parent R session?
Currently, if the main R session modifies the library paths, e.g.
> .libPaths()
[1] "/home/hb/R/x86_64-pc-linux-gnu-library/4.0-custom"
[2] "/home/hb/software/R-devel/tags/R-4-0-3/lib/R/library"
> .libPaths(c(tempdir(), .libPaths())
> .libPaths()
[1] "/tmp/hb/RtmpwLKdrG"
[2] "/home/hb/R/x86_64-pc-linux-gnu-library/4.0-custom"
[3] "/home/hb/software/R-devel/tags/R-4-0-3/lib/R/library"then we have to do:
> plan(multisession, workers = 2L, rscript_libs = .libPaths())for the multisession workers to see the same settings;
> libs <- value(future(.libPaths()))
> libs
[1] "/tmp/hb/RtmpwLKdrG"
[2] "/home/hb/R/x86_64-pc-linux-gnu-library/4.0-custom"
[3] "/home/hb/software/R-devel/tags/R-4-0-3/lib/R/library"The question here is whether or not rscript_libs = .libPaths() should be the default. One downside for it not being the default, is that it is up to the end-user to know that they should use plan(multisession, rscript_libs = .libPaths()) and not just plan(multisession). In contrast, they don't have to think about that when using plan(multicore) - it'll just work. This speaks for making rscript_libs = .libPaths() the new default for multisession futures.
I cannot come up with a good reason for not changing the default. I guess, local workers should inherit .libPaths() from the parent R process if they run a compatible version of R. For instance, it should definitely not use the same library paths if the main R session runs R 4.0.3 and the workers runs R 3.6.3. Depending on how R was built (compiler flags etc), we might also have incompatibility between different R 4.0.3 versions, which suggests we should only pass down .libPaths() if we run the exact same R installation (which is the default). Thus, we need to make sure this new default takes into account various corner cases like these. The easiest is probably to condition it on argument rscript not being specified.
cc/ @jcheng5, @aronatkins, @markusdumke
Activity
Now multisession workers inherit the package library path from the ma…
HenrikBengtsson commentedon Oct 24, 2020
Next release will have:
plan(multisession). To avoid this, useplan(multisession, rscript_libs = NULL), which is an argument passed down tomakeClusterPSOCK(). With this update, 'sequential', 'multisession', and 'multicore' futures see the exact same library path.