@@ -24,13 +24,18 @@ mutable struct File
24
24
options = _parsed_options (options)
25
25
_, _, file_frontmatter = raw_text_chunks (path)
26
26
merged_options = _extract_relevant_options (file_frontmatter, options)
27
- exeflags, env = _exeflags_and_env (merged_options)
27
+ exeflags, env, quarto_env = _exeflags_and_env (merged_options)
28
28
timeout = _extract_timeout (merged_options)
29
29
30
-
31
30
exe, _exeflags = _julia_exe (exeflags)
32
- worker =
33
- cd (() -> Malt. Worker (; exe, exeflags = _exeflags, env), dirname (path))
31
+ worker = cd (
32
+ () -> Malt. Worker (;
33
+ exe,
34
+ exeflags = _exeflags,
35
+ env = vcat (env, quarto_env),
36
+ ),
37
+ dirname (path),
38
+ )
34
39
file = new (
35
40
worker,
36
41
path,
@@ -104,7 +109,7 @@ function _julia_exe(exeflags)
104
109
end
105
110
106
111
function _extract_timeout (merged_options)
107
- daemon = merged_options[" format" ][" execute" ][" daemon" ]
112
+ daemon = something ( merged_options[" format" ][" execute" ][" daemon" ], true )
108
113
if daemon === true
109
114
300.0 # match quarto's default timeout of 300 seconds
110
115
elseif daemon === false
@@ -149,6 +154,13 @@ function _exeflags_and_env(options)
149
154
# if exeflags already contains '--color=no', the 'no' will prevail
150
155
pushfirst! (exeflags, " --color=yes" )
151
156
157
+ # Several QUARTO_* environment variables are passed to the worker process
158
+ # via the `env` field rather than via real environment variables. Capture
159
+ # these and pass them to the worker process separate from `env` since that
160
+ # is used by the worker status printout and we don't want these extra ones
161
+ # that the user has not set themselves to show up there.
162
+ quarto_env = Base. byteenv (options[" env" ])
163
+
152
164
# Ensure that coverage settings are passed to the worker so that worker
153
165
# code is tracked correctly during tests.
154
166
# Based on https://github.com/JuliaLang/julia/blob/eed18bdf706b7aab15b12f3ba0588e8fafcd4930/base/util.jl#L216-L229.
@@ -171,7 +183,7 @@ function _exeflags_and_env(options)
171
183
end
172
184
end
173
185
174
- return exeflags, env
186
+ return exeflags, env, quarto_env
175
187
end
176
188
177
189
struct Server
@@ -205,12 +217,14 @@ function init!(file::File, options::Dict)
205
217
end
206
218
207
219
function refresh! (file:: File , options:: Dict )
208
- exeflags, env = _exeflags_and_env (options)
220
+ exeflags, env, quarto_env = _exeflags_and_env (options)
209
221
if exeflags != file. exeflags || env != file. env || ! Malt. isrunning (file. worker) # the worker might have been killed on another task
210
222
Malt. stop (file. worker)
211
223
exe, _exeflags = _julia_exe (exeflags)
212
- file. worker =
213
- cd (() -> Malt. Worker (; exe, exeflags = _exeflags, env), dirname (file. path))
224
+ file. worker = cd (
225
+ () -> Malt. Worker (; exe, exeflags = _exeflags, env = vcat (env, quarto_env)),
226
+ dirname (file. path),
227
+ )
214
228
file. exe = exe
215
229
file. exeflags = exeflags
216
230
file. env = env
@@ -441,9 +455,11 @@ function _extract_relevant_options(file_frontmatter::Dict, options::Dict)
441
455
daemon = daemon_default,
442
456
params = params_default,
443
457
cache = cache_default,
458
+ env = Dict {String,Any} (),
444
459
)
445
460
else
446
461
format = get (D, options, " format" )
462
+ env = get (D, options, " env" )
447
463
execute = get (D, format, " execute" )
448
464
fig_width = get (execute, " fig-width" , fig_width_default)
449
465
fig_height = get (execute, " fig-height" , fig_height_default)
@@ -481,6 +497,7 @@ function _extract_relevant_options(file_frontmatter::Dict, options::Dict)
481
497
daemon,
482
498
params = params_merged,
483
499
cache,
500
+ env,
484
501
)
485
502
end
486
503
end
@@ -497,6 +514,7 @@ function _options_template(;
497
514
daemon,
498
515
params,
499
516
cache,
517
+ env,
500
518
)
501
519
D = Dict{String,Any}
502
520
return D (
@@ -515,6 +533,7 @@ function _options_template(;
515
533
" metadata" => D (" julia" => julia),
516
534
),
517
535
" params" => D (params),
536
+ " env" => env,
518
537
)
519
538
end
520
539
@@ -1466,7 +1485,7 @@ function run!(
1466
1485
chunk_callback = (i, n, c) -> nothing ,
1467
1486
)
1468
1487
try
1469
- borrow_file! (server, path; optionally_create = true ) do file
1488
+ borrow_file! (server, path; options, optionally_create = true ) do file
1470
1489
if file. timeout_timer != = nothing
1471
1490
close (file. timeout_timer)
1472
1491
file. timeout_timer = nothing
@@ -1606,7 +1625,7 @@ function borrow_file!(
1606
1625
get (server. workers, apath, nothing )
1607
1626
end
1608
1627
if file != = current_file
1609
- return borrow_file! (f, server, apath; optionally_create)
1628
+ return borrow_file! (f, server, apath; options, optionally_create)
1610
1629
else
1611
1630
return f (file)
1612
1631
end
0 commit comments