futureverse / futureverse/parallelly

makeClusterPSOCK(..., rscript_envs = ...) - more clever

Open
#8 8 comments 0 reactions 0 assignees View on GitHub
documentation
Dominant language
R
Stars
140
Forks
9
PR merge metrics
No merged PRs in 30d

Description

* `makeClusterPSOCK()` gained argument 'rscript_envs' for setting environment variables in workers on startup, e.g. `rscript_envs = c(FOO = "3.14", "BAR")`.

Instead of doing this [via `-e "Sys.setenv(''='')"` options](https://github.com/HenrikBengtsson/future/commit/107ed0dfb5c9d4860442c59b57e2c48d0600e43c), can't we do:
```
> Sys.setenv(FOO="bar")
> system2("Rscript", args = c("-e", shQuote("Sys.getenv('FOO')")), stdout=TRUE)
[1] "[1] \"bar\""
> my_undo_env_fcn()
```
This way we can set env vars that need to be set very early on in the R startup process in order to take place, e.g. `TMPDIR`.

I've verified that the above work on Linux and Windows. Maybe worth adding an internal `with_env()` to make sure things are properly undone for the main R session.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.