| 1 |
<!-- |
| 2 |
%\VignetteIndexEntry{Parallel Workers Running MS Windows via Wine} |
| 3 |
%\VignetteAuthor{Henrik Bengtsson} |
| 4 |
%\VignetteKeyword{R} |
| 5 |
%\VignetteKeyword{package} |
| 6 |
%\VignetteKeyword{vignette} |
| 7 |
%\VignetteEngine{parallelly::selfonly} |
| 8 |
--> |
| 9 |
|
| 10 |
|
| 11 |
# Introduction |
| 12 |
|
| 13 |
This vignette shows how to set up parallel workers running R for MS |
| 14 |
Windows via Wine (https://www.winehq.org/) on Linux and macOS. This |
| 15 |
can be useful when we need to run R code or call R packages that work |
| 16 |
only on MS Windows. |
| 17 |
|
| 18 |
The below instructions assume that you already have Wine installed. |
| 19 |
|
| 20 |
|
| 21 |
## Install R for MS Windows 11 |
| 22 |
|
| 23 |
To install R for MS Windows in Wine, first configure Wine to use |
| 24 |
Windows 11; |
| 25 |
|
| 26 |
```sh |
| 27 |
$ winecfg /v win11 |
| 28 |
$ winecfg /v |
| 29 |
win11 |
| 30 |
``` |
| 31 |
|
| 32 |
Then, install [R for Windows] in Wine, by: |
| 33 |
|
| 34 |
```sh |
| 35 |
$ wget https://cran.r-project.org/bin/windows/base/R-4.5.2-win.exe |
| 36 |
$ wine R-4.5.2-win.exe /SILENT |
| 37 |
``` |
| 38 |
|
| 39 |
Finally, verify that R is available in Wine; |
| 40 |
|
| 41 |
```sh |
| 42 |
$ wine "C:/Program Files/R/R-4.5.2/bin/x64/Rscript.exe" --version |
| 43 |
... |
| 44 |
Rscript (R) version 4.5.2 (2025-10-31) |
| 45 |
``` |
| 46 |
|
| 47 |
|
| 48 |
# Examples |
| 49 |
|
| 50 |
## Example: Parallel workers running MS Windows via Wine |
| 51 |
|
| 52 |
This example shows how to launch one worker running in Wine for Linux |
| 53 |
on the local machine. |
| 54 |
|
| 55 |
```r |
| 56 |
cl <- makeClusterPSOCK( |
| 57 |
1L, |
| 58 |
rscript = c( |
| 59 |
## Silence Wine warnings |
| 60 |
"WINEDEBUG=fixme-all", |
| 61 |
"LC_ALL=en_US.UTF-8", |
| 62 |
## Don't pass LC_* and R_LIBS* environments from host to Wine |
| 63 |
sprintf("%s=", grep("^(LC_|R_LIBS)", names(Sys.getenv()), value = TRUE)), |
| 64 |
"wine", |
| 65 |
"C:/Program Files/R/R-4.5.2/bin/x64/Rscript.exe" |
| 66 |
) |
| 67 |
) |
| 68 |
print(cl) |
| 69 |
#> Socket cluster with 1 node on host 'localhost' |
| 70 |
#> (R version 4.5.2 (2025-10-31 ucrt), platform x86_64-w64-mingw32) |
| 71 |
``` |
| 72 |
|
| 73 |
|
| 74 |
## Example: Installing packages in Wine |
| 75 |
|
| 76 |
We can install R packages as usual, e.g. |
| 77 |
|
| 78 |
```r |
| 79 |
void <- parallel::clusterEvalQ(cl[1], { |
| 80 |
chooseCRANmirror(ind = 1L) |
| 81 |
install.packages("future") |
| 82 |
}) |
| 83 |
``` |
| 84 |
|
| 85 |
|
| 86 |
# Appendix |
| 87 |
|
| 88 |
## Using a personal package library in Wine |
| 89 |
|
| 90 |
When using Wine, the system package library - the last one reported by |
| 91 |
`.libPaths()` - is owned by the users that installed R in Wine. This |
| 92 |
means that is _not_ write protected for most users and any package can |
| 93 |
be installed there. |
| 94 |
|
| 95 |
Sometimes its preferred to install packages to a personal package |
| 96 |
library. To do this, all we have to do is pre-create the personal |
| 97 |
package library in Wine. This can be done as: |
| 98 |
|
| 99 |
```r |
| 100 |
void <- parallel::clusterEvalQ(cl[1], { |
| 101 |
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE) |
| 102 |
}) |
| 103 |
``` |
| 104 |
|
| 105 |
To validate that the personal package library exists, _restart the |
| 106 |
cluster_. Then call: |
| 107 |
|
| 108 |
```r |
| 109 |
parallel::clusterEvalQ(cl[1], { .libPaths() })[[1]] |
| 110 |
[1] "C:/users/alice/AppData/Local/R/win-library/4.5" |
| 111 |
[2] "C:/PROG~FBU/R/R-45~RZJ.2/library" |
| 112 |
``` |
| 113 |
|
| 114 |
The first directory is the personal package library. |
| 115 |
|
| 116 |
|
| 117 |
## Wine and R warnings |
| 118 |
|
| 119 |
It might be that Wine produces warnings like: |
| 120 |
|
| 121 |
```plain |
| 122 |
0128:fixme:font:find_matching_face Untranslated charset 255 |
| 123 |
``` |
| 124 |
|
| 125 |
and R for Windows produces a warning on: |
| 126 |
|
| 127 |
```plain |
| 128 |
During startup - Warning message: |
| 129 |
Using locale code page other than 65001 ("UTF-8") may cause problems. |
| 130 |
``` |
| 131 |
|
| 132 |
These are typically harmless. Environment variable setting |
| 133 |
`WINEDEBUG=fixme-all` should take care of the first one, and |
| 134 |
`LC_ALL=en_US.UTF-8` the second one. |
| 135 |
|
| 136 |
|
| 137 |
## Windows-only CRAN packages |
| 138 |
|
| 139 |
A small number of the CRAN packages install only on MS Windows. Here |
| 140 |
is how to see which they are: |
| 141 |
|
| 142 |
```r |
| 143 |
db <- read.dcf(url("https://cran.r-project.org/src/contrib/PACKAGES")) |
| 144 |
db <- as.data.frame(db) |
| 145 |
win_only <- subset(db, OS_type == "windows") |
| 146 |
print(win_only$Package) |
| 147 |
``` |
| 148 |
|
| 149 |
As of 2026-03-03, this outputs: |
| 150 |
|
| 151 |
```r |
| 152 |
[1] "BiplotGUI" "blatr" "excel.link" |
| 153 |
[4] "KeyboardSimulator" "MDSGUI" "MediaNews" |
| 154 |
[7] "R2PPT" "R2wd" "rFUSION" |
| 155 |
[10] "RWinEdt" "spectrino" "taskscheduleR" |
| 156 |
``` |
| 157 |
|
| 158 |
[R for Windows]: https://cran.r-project.org/bin/windows/base/ |
| 159 |
[Winetricks]: https://github.com/Winetricks/winetricks |