Debian Codegraph @

inst/doc/parallelly-22-wine-workers.html

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