futureverse / futureverse/future
Re-enable forked processing in RStudio Jobs and RStudio Terminal?
- Dominant language
- R
- Stars
- 1k
- Forks
- 92
- PR merge metrics
- No merged PRs in 30d
Description
@graemeblair wrote in https://github.com/HenrikBengtsson/future/issues/299#issuecomment-501318832:
> Hi -- late to this, but wondering if `supportsMulticore()` should return `TRUE` when run within RStudio 1.2 "jobs" feature (and still `FALSE` when run interactively). As I understand it, when code is run through jobs it is separated from the GUI interactions that complicate using `plan(multicore)` in RStudio run interactively. This would enable the same scripts that use `plan(multicore)` to be used in and out of RStudio with a bit less hassle.
I took the conservative approach and disabled [forked processing anywhere in RStudio](https://github.com/HenrikBengtsson/future/issues/299) by testing for environment variable `RSTUDIO`.
It could be that it's only unsafe when running R via the RStudio Console (the "RStudio GUI"), but that it indeed works when running R via the RStudio Terminal (Tools -> Terminal -> New Terminal) or as an RStudio Job. I know one can distinguish RStudio Console from RStudio Terminal as:
```r
is_rstudio_console <- function() {
(Sys.getenv("RSTUDIO") == "1") && !nzchar(Sys.getenv("RSTUDIO_TERM"))
}
is_rstudio_terminal <- function() {
(Sys.getenv("RSTUDIO") == "1") && nzchar(Sys.getenv("RSTUDIO_TERM"))
}
```
Source: https://github.com/HenrikBengtsson/startup/blob/0.12.0/R/is_rstudio.R
1. Could someone check how to detect whether R via an RStudio Job or not?
2. Then we also need to reach out to the RStudio GUI folks about forked processing in the above three cases of running R from RStudio.
Contributor guide
Assessment
This issue has not been assessed yet.